Skip to content

Commit ae7edb4

Browse files
Merge pull request TheAlgorithms#135 from OskarEn/master
Create GCD.java
2 parents 0b82799 + edde956 commit ae7edb4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Misc/GCD.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//Oskar Enmalm 3/10/17
2+
//This is Euclid's algorithm which is used to find the greatest common denominator
3+
4+
public class GCD{
5+
6+
public static int gcd(int a, int b) {
7+
8+
int r = a % b;
9+
while (r != 0) {
10+
b = r;
11+
r = b % r;
12+
}
13+
return b;
14+
}
15+
}

0 commit comments

Comments
 (0)