Tau function: Difference between revisions

m (syntax highlighting fixup automation)
Line 2,137:
5 4 2 12 4 4 4 8 2 12
4 6 4 4 4 12 2 6 6 9
</pre>
 
=={{header|RPL}}==
{{trans|Python}}
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL Code
! Python code
|-
|
≪ → n
≪ 0 1
1 n √ '''FOR''' ii
'''IF''' n ii MOD NOT '''THEN'''
SWAP 1 + SWAP
DROP n ii / IP
'''IF''' DUP ii ≠
'''THEN''' SWAP 1 + SWAP '''END END'''
'''NEXT'''
DROP
≫ ≫ ‘TAU’ STO
|
''(n -- tau(n) )''
ans, j = 0, 1
while i*i <= n:
if 0 == n%i:
ans += 1
j = n//i
if j != i:
ans += 1
i += 1
return ans
.
|}
The following line of command delivers what is required:
≪ {} 1 100 '''FOR''' j j TAU + '''NEXT''' ≫ EVAL
{{out}}
<pre>
1: { 1 2 2 3 2 4 2 4 3 4 2 6 2 4 4 5 2 6 2 6 4 4 2 8 3 4 4 6 2 8 2 6 4 4 4 9 2 4 4 8 2 8 2 6 6 4 2 10 3 6 4 6 2 8 4 8 4 4 2 12 2 4 6 7 4 8 2 6 4 8 2 12 2 4 6 6 4 8 2 10 5 4 2 12 4 4 4 8 2 12 4 6 4 4 4 12 2 6 6 9 }
</pre>
 
1,150

edits