Tau function: Difference between revisions

no edit summary
m (Fix brain-o)
No edit summary
Line 1,210:
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>
 
=={{header|EMal}}==
{{trans|Java}}
<syntaxhighlight lang="emal">
fun divisorCount = int by int n
int total = 1
for ; (n & 1) == 0; n /= 2 do ++total end
for int p = 3; p * p <= n; p += 2
int count = 1
for ; n % p == 0; n /= p do ++count end
total *= count
end
if n > 1 do total *= 2 end
return total
end
int limit = 100
writeLine("Count of divisors for the first " + limit + " positive integers:")
for int n = 1; n <= limit; ++n
text value = text!divisorCount(n)
write((" " * (3 - value.length)) + value)
if n % 20 == 0 do writeLine() end
end
</syntaxhighlight>
{{out}}
<pre>
Count of divisors for the first 100 positive integers:
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>
 
=={{header|F_Sharp|F#}}==
224

edits