(umm... just finished dinner - Lasanga).
Here's some C code I cobbled together from the Ruby example.
Code:
#include <stdio.h>
int CalcGCD(int num1, int num2)
{
if ((num1 % num2) == 0) return num2; //num2 is the gcd
else return CalcGCD(num2, num1 % num2) ;
}
int main (int argc, const char * argv[])
{
printf("GCD of 200 and 5 is %i\n" , CalcGCD(200,5));
printf("GCD of 5 and 200 is %i\n" , CalcGCD(5,200));
printf("GCD of 200 and 3 is %i\n" , CalcGCD(200,3));
printf("GCD of 3 and 200 is %i\n" , CalcGCD(3,200));
printf("GCD of 4 and 6 is %i\n" , CalcGCD(4, 6));
printf("GCD of 6 and 4 is %i\n" , CalcGCD(6, 4));
return 0;
}
Todd