28 lines
499 B
Plaintext
28 lines
499 B
Plaintext
ClearAll[RepUnit, CircularPrimeQ]
|
|
RepUnit[n_] := (10^n - 1)/9
|
|
CircularPrimeQ[n_Integer] := Module[{id = IntegerDigits[n], nums, t},
|
|
AllTrue[
|
|
Range[Length[id]]
|
|
,
|
|
Function[{z},
|
|
t = FromDigits[RotateLeft[id, z]];
|
|
If[t < n,
|
|
False
|
|
,
|
|
PrimeQ[t]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
Select[Range[200000], CircularPrimeQ]
|
|
|
|
res = {};
|
|
Dynamic[res]
|
|
Do[
|
|
If[CircularPrimeQ[RepUnit[n]], AppendTo[res, n]]
|
|
,
|
|
{n, 1000}
|
|
]
|
|
|
|
Scan[Print@*PrimeQ@*RepUnit, {5003, 9887, 15073, 25031, 35317, 49081}]
|