Jump to content

Möbius function: Difference between revisions

→‎{{header|RPL}}: HP-49/50 version
(Add PARI/GP implementation)
(→‎{{header|RPL}}: HP-49/50 version)
Line 2,249:
'''NEXT'''
≫ '''END'''
≫ ''''<span style="color:blue">MU'''</span>' STO
|
'''<span style="color:blue">MU'''</span> ''( n -- µ(n) )''
if n = 1 then return 1
// default return value put in stack
Line 2,265:
|}
 
{{in}}
≪ 1 100 '''FOR''' li "" li DUP 19 + '''FOR''' j "-0+" j <span style="color:blue">MU</span> 2 + DUP SUB + '''NEXT''' 20 '''STEP''' ≫ EVAL
<pre>
 
≪ 1 100 FOR li "" li DUP 19 + FOR j "-0+" j MU 2 + DUP SUB + NEXT 20 STEP ≫ EVAL
</pre>
{{out}}
<pre>
Line 2,277 ⟶ 2,276:
1: "0+-0+++0-0+0+++0-000"
</pre>
{{works with|HP|49/50}}
Improvement of an implementation found on the [https://www.hpmuseum.org/forum/thread-10330-post-93200.html#pid93200 MoHPC forum]
« '''CASE'''
DUP 1 ≤ '''THEN END'''
FACTOR DUP TYPE 9 ≠ '''THEN''' DROP -1 '''END'''
DUP →STR "^" POS '''THEN''' DROP 0 '''END'''
SIZE 1 + 2 / 1 SWAP 2 MOD { NEG } IFT
'''END'''
» '<span style="color:blue">MU</span>' STO
« 1 100 '''FOR''' j
j 20 MOD 1 == "" IFT
"-0+" j <span style="color:blue">MU</span> 2 + DUP SUB +
'''NEXT'''
» '<span style="color:blue">TASK</span>' STO
Same output.
 
=={{header|Ruby}}==
1,150

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.