26 lines
639 B
Plaintext
26 lines
639 B
Plaintext
program arithmetic_derivative;
|
|
loop for n in [-99..100] do
|
|
nprint(lpad(str lagarias(n), 6));
|
|
if (col +:= 1) mod 10 = 0 then
|
|
print;
|
|
end if;
|
|
end loop;
|
|
|
|
loop for m in [1..20] do
|
|
nprint("D(10^" + lpad(str m, 2) + ") / 7 = ");
|
|
print(lagarias(10**m) div 7);
|
|
end loop;
|
|
|
|
proc lagarias(n);
|
|
return if n<0 then
|
|
-lagarias(-n)
|
|
elseif n in {0,1} then
|
|
0
|
|
elseif forall d in {2..floor sqrt n} | n mod d /= 0 then
|
|
1
|
|
else
|
|
(n div d)*lagarias(d) + d*lagarias(n div d)
|
|
end;
|
|
end proc;
|
|
end program;
|