Created
November 21, 2018 09:46
-
-
Save AmirSoleimani/c4b7435308fc5a121c4c35cba1e07024 to your computer and use it in GitHub Desktop.
GCD - Greatest Common Divisor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
->
354
,8
->
6