Practical numbers: Difference between revisions

→‎{{header|RPL}}: typo + benchmark for the Srinivasan-Stewart-Sierpinsky characterization method
(added RPL)
(→‎{{header|RPL}}: typo + benchmark for the Srinivasan-Stewart-Sierpinsky characterization method)
Line 1,590:
=={{header|RPL}}==
{{works with|HP|49/50}}
'''====Brute & slow force'''====
« 1 SF REVLIST
1 « '''IF''' 1 FS? '''THEN''' NOT '''IF''' DUP '''THEN''' 1 CF '''END END''' » DOLIST
Line 1,616:
» '<span style="color:blue">PRACTICAL?</span>' STO <span style="color:grey">@ ( n → boolean ) </span>
 
'''====Using Srinivasan-Stewart-Sierpinsky characterization'''====
From [https://en.wikipedia.org/wiki/Practical_number#Characterization_of_practical_numbers the Wikipedia article]. Fast and no special memory requirements.
« '''CASE'''
DUP LN 2 LN / FP NOT '''THEN''' SIGN '''END''' <span style="color:grey">@ powers of two are practical</span>
Line 1,628 ⟶ 1,629:
PICK3 j GET ^ *
-2 '''STEP'''
DROP2 2 FS?
'''END'''
» '<span style="color:blue">PRACTICAL?</span>' STO <span style="color:grey">@ ( n → boolean ) </span>
Line 1,647 ⟶ 1,648:
1: 0
</pre>
Non-practicality of 66666 is established in 0.57 sec on an HP-50 handheld calculator.
 
=={{header|Rust}}==
1,150

edits