http://qs321.pair.com?node_id=1157086


in reply to Recurring Cycle of Fractions

my $num = $ARGV[0]; my $den = $ARGV[1]; my $rem = $num%$den; my $rec; my $rec_exists; while ($rem) { $rem *= 10; my $quotient = int($rem/$den); if($rec =~ m/$quotient/) { $rec_exists = 1; last; } $rec .= int($rem/$den); $rem %= $den; } if ($rec_exists) { print "recurrence exists: $rec \n"; } else { print "no recurrence ..\n"; }