RosettaCodeData/Task/Tau-function/EMal/tau-function.emal

19 lines
534 B
Text
Raw Permalink Normal View History

2026-04-30 12:34:36 -04:00
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
2023-07-01 11:58:00 -04:00
end
2026-04-30 12:34:36 -04:00
if n > 1 do total *← 2 end
2023-07-01 11:58:00 -04:00
return total
end
2026-04-30 12:34:36 -04:00
int limit ← 100
2023-07-01 11:58:00 -04:00
writeLine("Count of divisors for the first " + limit + " positive integers:")
2026-04-30 12:34:36 -04:00
for int n ← 1; n ≤ limit; ++n
text value ← text!divisorCount(n)
2023-07-01 11:58:00 -04:00
write((" " * (3 - value.length)) + value)
2026-04-30 12:34:36 -04:00
if n % 20 æ 0 do writeLine() end
2023-07-01 11:58:00 -04:00
end