RosettaCodeData/Task/Tau-function/EMal/tau-function.emal
2026-04-30 12:34:36 -04:00

18 lines
534 B
Text

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