28 lines
689 B
Plaintext
28 lines
689 B
Plaintext
arithmeticDerivative: procedure options(main);
|
|
lagarias: procedure(n) returns(fixed);
|
|
declare (n, res, fac, rem) fixed;
|
|
rem = abs(n);
|
|
if rem<2 then return(0);
|
|
|
|
res = 0;
|
|
do while(mod(rem,2) = 0);
|
|
res = res + n/2;
|
|
rem = rem/2;
|
|
end;
|
|
|
|
do fac=3 repeat(fac+2) while(fac<=rem);
|
|
do while(mod(rem,fac) = 0);
|
|
res = res + n/fac;
|
|
rem = rem/fac;
|
|
end;
|
|
end;
|
|
return(res);
|
|
end lagarias;
|
|
|
|
declare n fixed;
|
|
do n=-99 to 100;
|
|
put edit(lagarias(n)) (F(7));
|
|
if mod(n+100, 10)=0 then put skip;
|
|
end;
|
|
end arithmeticDerivative;
|