Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 47s1 days 16 hours 1 minutes 47 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 47s1 days 16 hours 1 minutes 47 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.