RosettaCodeData/Task/Tau-function/PL-I/tau-function.pli

24 lines
589 B
Plaintext

taufunc: procedure options(main);
tau: procedure(nn) returns(fixed);
declare (n, nn, tot, pf, cnt) fixed;
tot = 1;
do n=nn repeat(n/2) while(mod(n,2)=0);
tot = tot + 1;
end;
do pf=3 repeat(pf+2) while(pf*pf<=n);
do cnt=1 repeat(cnt+1) while(mod(n,pf)=0);
n = n/pf;
end;
tot = tot * cnt;
end;
if n>1 then tot = tot * 2;
return(tot);
end tau;
declare n fixed;
do n=1 to 100;
put edit(tau(n)) (F(3));
if mod(n,20)=0 then put skip;
end;
end taufunc;