Program to find GCD of floating point numbers | Recursive function to return gcd of a and b ; base case ; Driver Function .
function gcd ( a , b ) { if ( a < b ) return gcd ( b , a ) ; if ( Math . abs ( b ) < 0.001 ) return a ; else return ( gcd ( b , a - Math . floor ( a / b ) * b ) ) ; } var a = 1.20 , b = 22.5 ; document . write ( gcd ( a , b ) . toFixed ( 1 ) ) ;