Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Recurring Cycle of Fractions

by Anonymous Monk
on Mar 08, 2016 at 14:57 UTC ( #1157086=note: print w/replies, xml ) Need Help??


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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1157086]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2020-11-28 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?