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

15 lines
385 B
Text

ClearAll[DeceptiveNumberQ]
DeceptiveNumberQ[n_Integer] := If[! PrimeQ[n], PowerMod[10, n - 1, 9 n] == 1]
c = 0;
out = Reap[Do[
If[DeceptiveNumberQ[i],
Sow[i];
c++;
If[c >= 1000, Break[]]
]
,
{i, 2, \[Infinity]}
]][[2, 1]];
Print["The first 100:"]
Multicolumn[Take[out, 100], Appearance -> "Horizontal"]
Print["The 1000th is: ", out[[1000]]]