Created
February 20, 2015 09:16
-
-
Save tolpp/90c3aa4649705ac43475 to your computer and use it in GitHub Desktop.
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
public class Euclid { | |
static int iterativeGCD(int m, int n){ | |
while(n != 0){ | |
int r = m % n; | |
m = n; | |
n = r; | |
} | |
return m; | |
} | |
static int recursiveGCD(int m, int n){ | |
if(n == 0) | |
return m; | |
else{ | |
return recursiveGCD(n, m % n); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment