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

11 lines
421 B
Text

ClearAll[PrimesDecade]
PrimesDecade[n_Integer] := Module[{bounds},
bounds = {PrimePi[10^n] + 1, PrimePi[10^(n + 1) - 1]};
Prime[Range @@ bounds]
]
ds = Union @@ Table[Union[Times @@@ Tuples[PrimesDecade[d], 2]], {d, 0, 4}];
Multicolumn[Take[ds, 100], {Automatic, 8}, Appearance -> "Horizontal"]
sel = Min /@ GatherBy[Select[ds, GreaterEqualThan[10]], IntegerLength];
Grid[{#, FirstPosition[ds, #][[1]]} & /@ sel]