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"; }
In reply to Re: Recurring Cycle of Fractions
by Anonymous Monk
in thread Recurring Cycle of Fractions
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |