Number theory course : youtube CodeNCode(2 Aug 2020 : Practice Problem added)

in fermat’s primality test :-
in this int a = 2 + rand() % (n - 3);
how doing modulo with (n-3) resulting a in range [2,n-2]?

Hey Waqar! I have a doubt from L15: Binomial coeff. using Modulo Inverse.
The return type of power in that program is ‘int’, however in the code of the function we are converting res to long long by multiplying it by 1LL. So why does the compiler not give any error? Thanks in advance.

Please make video on Chinese
remainder Theorem .

In lecture 17 you mentioned that the number of prime factors of a number will be <= Log(N)
Please explain that

Hey, Your youtube channel is deleted, I am not able to see more videos now.

When will, be able to see lectures again… @waqar_ahmad224

I am having difficulty debugging this code from L15 nCr % p.

Can you help me find out why it’s not giving the proper results and instead giving negative numbers and big positive numbers?

#include <bits/stdc++.h>

#define int long long
#define float long double
#define endl ‘\n’

const int p = 1e9 + 7;

using namespace std;

int power (int a, int n)
{
int r = 1, current = a;
while (n)
{
r *= current;
if (n&1)
{
r = ((r%p) * (current%p))%p;
}
n >>= 1;
current = ((current%p) * (current%p))%p;
}
return r;
}

int inverse (int x)
{
return power (x, p - 2) % p;
}

void solve()
{
int n, r;
cin >> n >> r;

int numerator = 1;
for (int i = 1; i <= n; ++i)
{
    numerator = ((numerator%p) * (i%p)) % p;
}

int denominator1 = 1;
for (int i = 1; i <= n - r; ++i)
{
    denominator1 = ((denominator1%p) * (i%p))%p;
}

int inverse1 = inverse (denominator1);

int denominator2 = 1;
for (int i = 1; i <= r; ++i)
{
    denominator2 = ((denominator2%p) * (i%p))%p;
}

int inverse2 = inverse (denominator2);

cout << ((numerator%p) * (inverse1%p) * (inverse2)%p) << endl;

}

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int t = 1;
cin >> t;

while (t--)
{
    solve();
}
return 0;

}

Hey @waqar_ahmad224, some of these videos have been taken down I guess ://
Please could you get those up? learning a lot from your content!!

Bro youre links are not working

Did you find that approach brother