Skip to content

Instantly share code, notes, and snippets.

@gciruelos
Forked from jsharf/gcd.h
Last active December 18, 2015 18:08
Show Gist options
  • Save gciruelos/5823123 to your computer and use it in GitHub Desktop.
Save gciruelos/5823123 to your computer and use it in GitHub Desktop.
int gcd(int a, int b)
{
return (a%b==0)?b:gcd(b,a%b); //Jacob
}
int gcd2(int a, int b)
{
//iterative version
int temp;
while (a)
{
temp = b;
b = a;
a = a%temp;
}
return b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment