GCD (Greatest Common Divisor)
Basic
import math
math.gcd(2, 8) # result: 2
math.gcd(5, 15) # result: 5
math.gcd(28, 72) # result: 4# Calculate a remainder of 72/28
72 % 28 = 16
# Calculate a remainder using the previous number 16
28 % 16 = 12
# Repeat...
16 % 12 = 4
12 % 4 = 0Extended Euclidean Algorithm
Co-prime Numbers
References
Last updated