A258706 Absolute primes: every permutation of digits is a prime. Only the smallest representative of each permutation class is shown.
2, 3, 5, 7, 11, 13, 17, 37, 79, 113, 199, 337, 1111111111111111111, 11111111111111111111111
Offset: 1
Links
- M. F. Hasler, Table of n, a(n) for n = 1..15
- James Grime and Brady Haran, Absolute Primes, YouTube Numberphile video, 2024.
Programs
-
Haskell
import Data.List (permutations, (\\)) a258706 n = a258706_list !! (n-1) a258706_list = f a000040_list where f ps'@(p:ps) | any (== 0) (map a010051' dps) = f ps | otherwise = p : f (ps' \\ dps) where dps = map read $ permutations $ show p -- Reinhard Zumkeller, Jun 10 2015
-
Mathematica
Flatten@{2, 3, 5, 7, Table[Select[ Table @@ Prepend[Prepend[ Table[{A@k, A[k - 1], 4}, {k, 2, n}], {A[1], 4}], Unevaluated[ Unevaluated[FromDigits[{1, 3, 7, 9}[[A /@ Range[n]]]]]]] // Flatten, Function[L, And[PrimeQ[#], And @@ PrimeQ[ FromDigits /@ (Permute[L, #] & /@ RandomPermutation[Length@L, 5])], And @@ PrimeQ[FromDigits /@ Rest[Permutations[L]]]]]@ IntegerDigits@# &], {n, 2, 33}]} (* Exhaustively searches thru 33 digits in ~7.5 sec, and up to 69 digits in 5 min, but cannot reach 317 digits. Not helpful in the light of Schroeppel's theorem that it's all repunits past 991. - Bill Gosper, Jan 06 2017 *)
-
PARI
{A=[2,5]; for(n=1, 317, my(D=[1,3,7,9], r=10^n\9); for(a=1,4, for(b=a^(n<3),4, for(j=0, if(b!=a,n-1), ispseudoprime(D[a]*r+(D[b]-D[a])*10^j)||next(2)); A=setunion(A, [r*D[a]+(D[b]-D[a])*10^if(b=n[1] && #select(d->d,n[^1]-n[^-1])<2 && !for(i=1,(#n)^(n[#n]>1), isprime(fromdigits(n=concat(n[^1],n[1])))||return)} \\ By Johnson's theorem and minimality required here, the number must be of the form ab...b or a...ab (=> first difference of digits has at most 1 nonzero component) and then is sufficient to consider rotations of the digits. \\ M. F. Hasler, Jun 26 2018
Comments