Instantly share code, notes, and snippets.

Embed
What would you like to do?
GCD - Greatest Common Divisor
package cryptogcd
//GCD Greatest Common Divisor (Factor)
func GCD(a, b int) int {
var Remainder int
for {
Remainder = a % b
a = b
b = Remainder
if b == 0 {
break
}
}
return a
}
@AmirSoleimani

This comment has been minimized.

Owner

AmirSoleimani commented Nov 21, 2018

GCD is known as the greatest common divisor, or greatest common factor (gcf), and is the largest positive integer that divides into two numbers without a remainder. For example, the GCD of 9 and 15 is 3. It is an operation that is used many encryption algorithms

Sample:
9, 15 -> 3
54, 8 -> 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment