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

Re^4: Determining if a rational number terminates

by tobyink (Abbot)
on Nov 29, 2012 at 20:13 UTC ( #1006349=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Determining if a rational number terminates
in thread Determining if a rational number terminates

Meh... I was actually only checking multiples of five. D'oh! 1/15 was reporting "Y".

Fixed...

@ARGV = (15, 40); sub _{@i=sort{$b-$a}@_;return$i[1]if$i[0]==$i[1];@i=($i[1],$i[0]%$i[1 ])while$i[1];$i[0]}sub __{$j=_@_;$_/=$j for@_;$_[1]<0and do{$_*=-1for @_}}__(($k,$l)=@ARGV);for(2,5){$l/=$_ until$l%$_}print$l eq 1?Y:N,$/#
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^4: Determining if a rational number terminates
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-12-21 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls