Skip to content

Instantly share code, notes, and snippets.

@atomictom
Created February 6, 2014 01:23
Show Gist options
  • Save atomictom/8836797 to your computer and use it in GitHub Desktop.
Save atomictom/8836797 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int64_t gcd(int64_t a, int64_t b){
if(!b)
return a;
return gcd(b, a%b);
}
int64_t gcd2(int64_t a, int64_t b){
while(b){
int64_t temp = a%b;
a = b;
b = temp;
}
return a;
}
int main(){
printf("%ld\n", gcd2(121, 11));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment