use bigint; $x=<>; $y=$x=~s/\.//?10**length$':1; $x+=0; $y+=0; while($x){ ($x,$y)=($y%$x,$x); ++$i; } print$i;