Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Determining if a rational number terminates

by tobyink (Canon)
on Nov 29, 2012 at 20:13 UTC ( [id://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'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-03-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found