Concepts6
Harmonic Lemma
The Harmonic Lemma says that the values of \lfloor n/i \rfloor only change about 2\sqrt{n} times, so you can iterate those value blocks in O(\sqrt{n}) instead of O(n).
Inclusion-Exclusion Principle
The Inclusion-Exclusion Principle (IEP) corrects overcounting by alternately adding and subtracting sizes of intersections of sets.
MΓΆbius Function and Inversion
The MΓΆbius function ΞΌ(n) is 0 if n has a squared prime factor, otherwise it is (-1)^k where k is the number of distinct prime factors.
Divisor Function Sums
Summing the divisor function d(i) up to n equals counting lattice points under the hyperbola xy β€ n, which can be done in O(βn) using floor-division blocks.
Multiplicative Functions
A multiplicative function is an arithmetic function f with f(mn) = f(m)f(n) whenever gcd(m, n) = 1.
Euler's Totient Function
Euler's Totient Function Ο(n) counts how many integers from 1 to n are coprime with n.