Using Euclid Algorithm to find GCF(GCD)
I am trying to write a function to find the gcd of 2 numbers, using Euclid's Algorithm which I found here . From the larger number, subtract the smaller number as many times as you can until you have a number that is smaller than the small number. (or without getting a negative answer) Now, using the original small number and the result, a smaller number, repeat the process. Repeat this until the last result is zero, and the GCF is the next-to-last small number result. Also see our Euclid's Algorithm Calculator. Example: Find the GCF (18, 27) 27 - 18 = 9 18 - 9 = 9 9 - 9 = 0 So, the greatest