Skip to content

Instantly share code, notes, and snippets.

@tolpp
Created February 20, 2015 09:16
Show Gist options
  • Save tolpp/90c3aa4649705ac43475 to your computer and use it in GitHub Desktop.
Save tolpp/90c3aa4649705ac43475 to your computer and use it in GitHub Desktop.
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