RosettaCodeData/Task/Chowla-numbers/Mathematica/chowla-numbers.math
2023-07-01 13:44:08 -04:00

12 lines
549 B
Text

ClearAll[Chowla]
Chowla[0 | 1] := 0
Chowla[n_] := DivisorSigma[1, n] - 1 - n
Table[{i, Chowla[i]}, {i, 37}] // Grid
PrintTemporary[Dynamic[n]];
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 100, 2}]; i
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 1000, 2}]; i
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 10000, 2}]; i
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 100000, 2}]; i
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 1000000, 2}]; i
i = 1; Do[If[Chowla[n] == 0, i++], {n, 3, 10000000, 2}]; i
Reap[Do[If[Chowla[n] == n - 1, Sow[n]], {n, 1, 35 10^6}]][[2, 1]]