Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Recurring Cycle of Fractions

by Anonymous Monk
on Mar 08, 2016 at 14:57 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1157086]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found