<?xml version="1.0" encoding="windows-1252"?>
<node id="1006294" title="Re: Determining if a rational number terminates" created="2012-11-29 11:27:49" updated="2012-11-29 11:27:49">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;Nicely obfuscated, but this is shorter:&lt;/p&gt;
&lt;del&gt;&lt;c&gt;
$_=pop;$_/=2until$_%2;print/(5|^1)$/?Y:N,$/
&lt;/c&gt;&lt;/del&gt;
&lt;c&gt;
$_=pop;for$.(2,5){$_/=$.until$_%$.}print/^1$/?Y:N,$/
&lt;/c&gt;
&lt;p&gt;Of course, neither of these works for the fraction 3/6 which of course terminates as 0.5. For that to work, you'd need to add an initial step to reduce the fraction to its lowest terms.&lt;/p&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">
1006283</field>
</data>
</node>
