Sequence: smallest number with exactly n divisors: Difference between revisions

add RPL
No edit summary
(add RPL)
Line 1,950:
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49g}}
≪ {1}
2 ROT '''FOR''' j
1
'''DO''' 1 + '''UNTIL''' DUP DIVIS SIZE j == '''END'''
+
'''NEXT '''
≫ '<span style="color:blue">TASK</span>' STO
 
15 <span style="color:blue">TASK</span>
{{out}}
<pre>
1: {1 2 4 6 16 12 64 24 36 48 1024 60 4096 192 144}
</pre>
Runs in 13 minutes on an HP-50g.
====Faster implementation====
With the hint given in the [https://oeis.org/A005179 OEIS page] that a(p)=2^(p-1) when p is prime:
≪ {1}
2 ROT '''FOR''' j
'''IF''' j ISPRIME? '''THEN''' 2 j 1 - ^
'''ELSE'''
1 '''DO''' 1 + '''UNTIL''' DUP DIVIS SIZE j == '''END'''
'''END'''
+
'''NEXT '''
≫ '<span style="color:blue">TASK</span>' STO
the same result is obtained in less than a minute.
 
=={{header|Ruby}}==
1,151

edits