This package contains basic tasks in number theory
- Prime factors of a number
- All factors of a number
- Sieve of Eratosthenes
- Euler's totient function
- Number of natural numbers up to n which are coprime to n
- A−n mod X = (A−1 mod X)n mod X = (Aφ(X)−1 mod X)n mod X
- Gauss proves that a regular n-gon can be constructed with straightedge and compass if φ(n) is a power of 2
- summation of lcm & gcd
- Lucas Theorem
- Finds nCr mod m, where m is prime & n > m. Complexity O(m + logm n * log m)
- Exponentiation by Squaring
- fast computation of large positive integer powers of a number in O(log N)
- Chicken McNugget Theorem
ifgcd(m, n) = 1then all nos >mn-m-ncan be written in the formam + bn
Problem: I Hate 1111 - a1 + a2 + ... = S.
max(Σa1a2..) is when a1 = a2 = ...
Problem: Subdivided Slimes - Area of a polygon by Pick's theorem
A = B / 2 + I - 1
B: No. of boundary points I: No. of internal points
Problem: Integral Points - repeated digit sum or digital root of n
n-9*floor((n-1)/9) - min(Σ|X - ai|) = median of A.
Problem: Consecutive Snakes