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

Sign in to watch this lesson
Advanced - Number Theory · 4:06
Euclid's algorithm finds gcd(a, b); the extended version also finds integers x and y with a·x + b·y = gcd(a, b). We run Euclid down on (55, 80) keeping the quotients, carry the coefficients back up from (1, 0) to get 55·3 + 80·(−2) = 5, unroll the recursion into a loop with two invariants, and use it to compute modular inverses for any modulus, where Fermat's shortcut fails.