Module M34 · 34 of 35 in teaching order · Intermediate

Math

Overflow, modular arithmetic, primes, fast exponentiation and counting.

Lessons

  1. Why gcd(a, b) = gcd(b, a mod b), how fast the remainders shrink, the Fibonacci worst case, computing the lcm without overflow, and what each language provides.

  2. List every prime up to n by crossing out multiples: why marking starts at p², why the outer loop stops at √n, and where the O(n log log n) bound comes from.

Topics this module covers

The full module scope. Topics without a lesson above are not written yet.

  • overflow
  • modulo
  • GCD/Euclid/LCM
  • primes
  • sieve
  • factorization
  • binary exponentiation
  • combinatorics
  • permutations
  • randomness

Builds toward