Product of divisors: Difference between revisions

(→‎{{header|Clojure}}: Add implementation.)
Line 1,632:
2116 47 254803968 343 125000
done...
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
DUP 1 1 ROT √ '''FOR''' k
OVER k
'''IF''' DUP2 MOD '''NOT'''
'''THEN''' DUP2 SQ ≠ ROT ROT '''IFTE''' *
'''ELSE''' DROP2 '''END'''
'''NEXT''' SWAP DROP
≫ ‘PRODIV’ STO
|
''( n -- div1 *..*divn )''
Initialize result and loop
Put n and k in stack
if k divides n then
multiply by n or k, depending on n ≠ k²
otherwise drop both n and k
get rid of n
|}
The following line of command delivers what is required:
≪ {} 1 50 '''FOR''' j j '''PRODIV''' + '''NEXT''' ≫ EVAL
{{out}}
<pre>
1: { 1 2 3 8 5 36 7 64 27 100 11 1728 13 196 225 1024 17 5832 19 8000 441 484 23 331776 125 676 729 21952 29 810000 31 32768 1089 1156 1225 10077696 37 1444 1521 2560000 41 3111696 43 85184 91125 2116 47 254803968 343 125000 }
</pre>
 
Line 1,685 ⟶ 1,717:
41 3111696 43 85184 91125
2116 47 254803968 343 125000</pre>
 
 
=={{header|Verilog}}==
1,150

edits