Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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
Domain Nodelet?
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 musing on the Monastery: (3)
As of 2022-09-26 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (118 votes). Check out past polls.

    Notices?