Here is my code in C.
long int gcd(long int a,long int b)
long int g;
n = (long int)(n * 10000); //since maximum number of digits after the decimal place is 4
g = gcd(n,10000); //gcd will let me reduce the fraction into it's lowest form
printf("%ld\n",10000/g); 10000/g will be the new denominator after dividing by gcd