Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Circular-primes/Mathematica/circular-primes.math
Normal file
27
Task/Circular-primes/Mathematica/circular-primes.math
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue