<?xml version="1.0" encoding="windows-1252"?>
<node id="1006301" title="Re^2: Determining if a rational number terminates" created="2012-11-29 11:52:23" updated="2012-11-29 11:52:23">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;There are probably shorter ways of doing it, but...&lt;/p&gt;
&lt;c&gt;
# It is important to clearly comment your code to make it easier
# for future maintainers.
#

# This is the numerator, denominator pair for which we wish to
# determine if the decimal expansion terminates.
#
@ARGV = (33, 660);

# Check if it terminates and print "Y" or "N".
#
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]&lt;0and do{$_*=
-1for@_}}__(($k,$l)=@ARGV);$l/=2until$l%2;print$l=~/(5|^1)$/?Y:N,$/
&lt;/c&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1006283</field>
<field name="parent_node">
1006294</field>
</data>
</node>
