39 lines
496 B
Plaintext
39 lines
496 B
Plaintext
CARD FUNC DivisorCount(CARD n)
|
|
CARD result,p,count
|
|
|
|
result=1
|
|
WHILE (n&1)=0
|
|
DO
|
|
result==+1
|
|
n=n RSH 1
|
|
OD
|
|
|
|
p=3
|
|
WHILE p*p<=n
|
|
DO
|
|
count=1
|
|
WHILE n MOD p=0
|
|
DO
|
|
count==+1
|
|
n==/p
|
|
OD
|
|
result==*count
|
|
p==+2
|
|
OD
|
|
|
|
IF n>1 THEN
|
|
result==*2
|
|
FI
|
|
RETURN (result)
|
|
|
|
PROC Main()
|
|
CARD max=[100],n,divCount
|
|
|
|
PrintF("Tau function for the first %U numbers%E",max)
|
|
FOR n=1 TO max
|
|
DO
|
|
divCount=DivisorCount(n)
|
|
PrintC(divCount) Put(32)
|
|
OD
|
|
RETURN
|