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

Hey I need help in this problem

In this problem you have made a video covering the case where mod>=N but what to do when mod<= N as in this case given mod is 1009

Can You please Create a PDF of practice Questions that cover all the topics. :pray::pray:

Just a suggestion, can you make your presentations in dark theme?

@wakar_ahmad224 you show how we how calculate gcd sum like (gcd(1,n)+gcd(2,n)+…+gcd(n,n)).
but i want to calculate lcm sum. Given N and find lcm sum like (lcm(1,n)+lcm(2,n)+…+lcm(n,n)).
how can i approach please help me out anyone. TIA.

Pls dont forget the course im impatient for learn pollar rho algorithm

hey,i have used same logic as u taught,but i am getting TLE.why>???
here is my code,
n,q=map(int,input().split())

find the prime factorization of n

def factor(n):
res=[]
i=2
total=1
while ii<=n:
if n%i==0:
c=0
while n%i==0:
c+=1
n//=i
res.append([i,c])
total
=(c+1)
i+=1
if n>1:
res.append([n,1])
total*=2
return res,total

common divisor

def common(n,res,k):
ans=1
for i in res:
c=0
a=i[0]
while k%a==0:
c+=1
k//=a
ans*=(min(i[1],c)+1)
return ans

res,total=factor(n)
for i in range(q):
t,k=map(int,input().split())
if t==1:
ans=common(n,res,k)
print(ans)
elif t==2:
if k>n:
print(0)
else:
ans=1
for i in res:
c=0
a=i[0]
while k%a==0:
c+=1
k//=a
if c>i[1]:
ans=0
break
ans*=(i[1]-c+1)
if k>1:
print(0)
else:
print(ans)
else:
if k>n:
ans=0
else:
ans=1
for i in res:
c=0
a=i[0]
while k%a==0:
c+=1
k//=a
if c>i[1]:
ans=0
break
ans*=(i[1]-c+1)
print(total-ans)

G(1) = 1, G(2) = 1. G(n) = aG(n-1) + bG(n-2) + c. Suppose this is our recurrence relation then?

hii im getting wrong answer when i submit using sieve in this code can you help pls
problem link :
spoj etf
mycode: ideone link

In [SPOJ.com - Problem PRIME1] while initializing the sieve, why did we write
if(i != p)
- YouTube

Please explain. Thanks.

@waqar_ahmad224 can you tell me why i am getting TLE in this submission
https://www.codechef.com/viewsolution/47359228

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