19 lines
508 B
Plaintext
19 lines
508 B
Plaintext
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
|