⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 19s17 days 22 hours 19 minutes 19 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 19s17 days 22 hours 19 minutes 19 seconds.

Sign in to watch this lesson
Algorithms - Bits and Number Theory · 4:51
Addition, subtraction and multiplication can be reduced modulo m at every step, but division needs an inverse, and the clock picture shows when one exists: multiplying by 3 on the mod-7 clock visits every hour, while 2 on the mod-4 clock never reaches 1, so a has an inverse exactly when gcd(a, m) = 1. We compare extended Euclid (any coprime modulus), Fermat's a^(p-2) (prime modulus only) and the linear-time table, cover the C++ traps with negative % and overflowing products, and finish with the batch trick that inverts a million numbers with a single exponentiation, measured on this Mac.