Anti-primes: Difference between revisions
→Creating RPL entry
Deadmarshal (talk | contribs) (Added Modula-3) Tag: Made through Tor |
|||
Line 3,392:
done...
</pre>
=={{header|RPL}}==
We use here complex numbers to limit the stack size and ease its handling.
{{works with|Halcyon Calc|4.2.7}}
≪ → nb
≪ 1 1 nb 2 / FOR j
nb j MOD NOT +
NEXT
≫
≫
‘NDIV’ STO
≪ 1 - → items
≪ { } (2,0)
DO
DUP RE NDIV
IF OVER IM OVER < THEN
SWAP RE SWAP R→C
SWAP OVER RE + SWAP
ELSE
DROP
END
1 +
UNTIL OVER SIZE items > END
DROP
≫
≫
‘ANTIP’ STO
15 ANTIP
{{out}}
<pre>
{ 1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 }
</pre>
Line 3,397 ⟶ 3,429:
<syntaxhighlight lang="ruby">require 'prime'
{{works with|Halcyon Calc|4.2.7}}
def num_divisors(n)
n.prime_division.inject(1){|prod, (_p,n)| prod *= (n + 1) }
|