3. Let’s Start With Maths...
To become a Pupil you need two things Maths and Maths
1.Prime Testing
2. Divisors and Prime Factors
3.GCD and LCM
4.Binary Expo
5.Modular Arithmetic
6.Permutations
CONTENTS
7. GCD AND LCM
int gcd(int a,int b)
{
if(a%b==0)
return b;
else
return gcd(b,a%b);
}
8. Binary Expo
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
10. Modular Arithmetic
( a + b) % c = ( ( a % c ) + ( b % c ) ) % c
( a * b) % c = ( ( a % c ) * ( b % c ) ) % c
( a – b) % c = ( ( a % c ) – ( b % c ) ) % c
1.
2.
3.
Factorial wala example