cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-4 of 4 results.

A003459 Absolute primes (or permutable primes): every permutation of the digits is a prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 199, 311, 337, 373, 733, 919, 991, 1111111111111111111, 11111111111111111111111
Offset: 1

Views

Author

Keywords

Comments

From Bill Gosper, Jan 24 2003, in a posting to the Math Fun Mailing List: (Start)
Recall Sloane's old request for more terms of A003459 = (2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 199 311 337 373 733 919 991 ...) and Richard C. Schroeppel's astonishing observation that the next term is 1111111111111111111. Absent Rich's analysis, trying to extend this sequence makes a great set of beginner's programming exercises. We may restrict the search to combinations of the four digits 1,3,7,9, only look at starting numbers with nondecreasing digits, generate only unique digit combinations, and only as needed. (We get the target sequence afterward by generating and merging the various permutations, and fudging the initial 2,3,5,7.)
To my amazement the (uncompiled, Macsyma) program printed 11,13,...,199,337, and after about a minute, 1111111111111111111!
And after a few more minutes, (10^23-1)/9! (End)
Boal and Bevis say that Johnson (1977) proves that if there is a term > 1000 with exactly two distinct digits then it must have more than nine billion digits. - N. J. A. Sloane, Jun 06 2015
Some authors require permutable or absolute primes to have at least two different digits. This produces the subsequence A129338. - M. F. Hasler, Mar 26 2008
See A039986 for a related problem with more sophisticated (PARI) code (iteration over only inequivalent digit permutations). - M. F. Hasler, Jul 10 2018

References

  • Richard C. Schroeppel, personal communication.
  • Wacław Sierpiński, Co wiemy, a czego nie wiemy o liczbach pierwszych. Warsaw: PZWS, 1961, pp. 20-21.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 113.

Crossrefs

Includes all of A004022 = A002275(A004023).
A258706 gives minimal representatives of the permutation classes.
Cf. A039986.

Programs

  • Haskell
    import Data.List (permutations)
    a003459 n = a003459_list !! (n-1)
    a003459_list = filter isAbsPrime a000040_list where
       isAbsPrime = all (== 1) . map (a010051 . read) . permutations . show
    -- Reinhard Zumkeller, Sep 15 2011
    
  • Mathematica
    f[n_]:=Module[{b=Permutations[IntegerDigits[n]],q=1},Do[If[!PrimeQ[c=FromDigits[b[[m]]]],q=0;Break[]],{m,Length[b]}];q];Select[Range[1000],f[#]>0&] (* Vladimir Joseph Stephan Orlovsky, Feb 03 2011 *)
    (* Linear complexity: can't reach R(19). See A258706. - Bill Gosper, Jan 06 2017 *)
  • PARI
    for(n=1, oo, my(S=[],r=10^n\9); for(a=1, 9^(n>1), for(b=if(n>2, 1-a), 9-a, for(j=0, if(b, n-1), ispseudoprime(a*r+b*10^j)||next(2)); S=concat(S,vector(if(b,n,1),k,a*r+10^(k-1)*b))));apply(t->printf(t","),Set(S))) \\ M. F. Hasler, Jun 26 2018

Formula

Conjecture: for n >= 23, a(n) = A004022(n-21). - Max Alekseyev, Oct 08 2018

Extensions

The next terms are a(25)=A002275(317), a(26)=A002275(1031), a(27)=A002275(49081).

A317688 Absolute primes that are not repunits: primes where the number resulting from any permutation of the digits is also prime, excluding repunit primes.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 199, 311, 337, 373, 733, 919, 991
Offset: 1

Views

Author

Felix Fröhlich, Aug 04 2018

Keywords

Comments

Any term with two or more digits contains exactly two different digits from the set {1, 3, 7, 9} (cf. Erdős et al., 1977, Solution 953).
Conjecture: The sequence is finite, with 991 being the last term.
The known terms are those terms of A293663 where membership in A293663 trivially implies membership in this sequence, i.e., the numbers resulting from all cyclic permutations of the digits of these terms are the same as the numbers resulting from all permutations of the digits of these terms. This is the case only for terms with less than four digits.

Examples

			The other numbers resulting from all possible permutations of the digits of 113 are 131 and 311. 113, 131 and 311 are all primes, so all three numbers are terms of this sequence.
		

Crossrefs

Relative complement of A004022 in A003459. Supersequence of A129338. Subsequence of A293663.

Programs

  • PARI
    eva(n) = subst(Pol(n), x, 10)
    find_index_a(vec) = my(r=#vec-1); while(1, if(vec[r] < vec[r+1], return(r)); r--; if(r==0, return(-1)))
    find_index_b(r, vec) = my(s=#vec); while(1, if(vec[r] < vec[s], return(s)); s--; if(s==r, return(-1)))
    switch_elements(vec, firstpos, secondpos) = my(g); g=vec[secondpos]; vec[secondpos]=vec[firstpos]; vec[firstpos] = g; vec
    reverse_order(vec, r) = my(v=[], w=[]); for(x=1, r, v=concat(v, vec[x])); for(y=r+1, #vec, w=concat(w, vec[y])); w=Vecrev(w); concat(v, w)
    next_permutation(vec) = my(r=find_index_a(vec)); if(r==-1, return(0), my(s=find_index_b(r, vec)); vec=switch_elements(vec, r, s); vec=reverse_order(vec, r)); vec
    is(n) = if(n < 10, return(1)); my(d=vecsort(digits(n))); if(vecmin(d)==0 || vecmax(d)==1, return(0)); while(1, if(!ispseudoprime(eva(d)), return(0)); d=next_permutation(d); if(d==0, return(1)))
    forprime(p=1, , if(is(p), print1(p, ", ")))

A317689 Largest nonrepunit base-n absolute prime (conjectured).

Original entry on oeis.org

7, 53, 3121, 211, 1999, 3803, 6469, 991, 161047, 19793, 16477, 24907, 683437, 3547, 67853, 80273, 94109, 72421
Offset: 3

Views

Author

Felix Fröhlich, Aug 04 2018

Keywords

Comments

A base-b permutable or absolute prime is a prime p such that all numbers obtained from every permutation of the base-b digits of p and converted to base 10 are prime.
These primes were found using lim=10^8 in the PARI program and match those found with lim=10^5, lim=10^6 and lim=10^7. Therefore I conjecture that they are the correct values for those n.

Crossrefs

Programs

  • PARI
    find_index_a(vec) = my(r=#vec-1); while(1, if(vec[r] < vec[r+1], return(r)); r--; if(r==0, return(-1)))
    find_index_b(r, vec) = my(s=#vec); while(1, if(vec[r] < vec[s], return(s)); s--; if(s==r, return(-1)))
    switch_elements(vec, firstpos, secondpos) = my(g); g=vec[secondpos]; vec[secondpos]=vec[firstpos]; vec[firstpos] = g; vec
    reverse_order(vec, r) = my(v=[], w=[]); for(x=1, r, v=concat(v, vec[x])); for(y=r+1, #vec, w=concat(w, vec[y])); w=Vecrev(w); concat(v, w)
    next_permutation(vec) = my(r=find_index_a(vec)); if(r==-1, return(0), my(s=find_index_b(r, vec)); vec=switch_elements(vec, r, s); vec=reverse_order(vec, r)); vec
    decimal(v, base) = my(w=[]); for(k=0, #v-1, w=concat(w, v[#v-k]*base^k)); sum(i=1, #w, w[i])
    is_absolute_prime(n, base) = my(db=vecsort(digits(n, base))); if(vecmin(db)==0 || vecmax(db)==1, return(0)); while(1, my(dec=decimal(db, base)); if(!ispseudoprime(dec), return(0)); db=next_permutation(db); if(db==0, return(1)))
    a(n) = my(absp=0, lim=10^7, i=0); forprime(p=n+1, , if(is_absolute_prime(p, n), absp=p); i++; if(i==lim, return(absp)))

A298643 Array A(n, k) read by antidiagonals downwards: k-th base-n non-repunit prime p such that all numbers resulting from switching any two adjacent digits in the base-n representation of p are prime, where k runs over the positive integers, i.e., the offset of k is 1.

Original entry on oeis.org

11, 191, 2, 223, 5, 2, 227, 7, 3, 2, 2111, 17, 7, 3, 2, 3847, 31, 13, 7, 3, 2, 229631, 41, 23, 11, 5, 3, 2, 246271, 53, 29, 13, 11, 5, 3, 2, 262111, 157, 47, 17, 31, 11, 5, 3, 2, 786431, 229, 53, 19, 47, 13, 7, 5, 3, 2, 1046527, 239, 101, 23, 71, 17, 13, 7, 5
Offset: 2

Views

Author

Felix Fröhlich, Jan 24 2018

Keywords

Comments

Conjecture: All rows of the array are infinite.
If the above conjecture is false, then this should have keyword "tabf" rather than "tabl".
Row n is a supersequence of the base-n non-repunit absolute primes. For example, row 10 (A107845) is a supersequence of the decimal non-repunit absolute primes (A129338).

Examples

			The base-3 representation of 251 is 100022. Base-3 numbers that can be obtained by switching any two adjacent base-3 digits are 10022 and 100202. These two numbers are 89 and 263, respectively, when converted to decimal, and both 89 and 263 are prime. Since 251 is the 12th number with this property in base 3, A(3, 12) = 251.
Array starts
11, 191, 223, 227, 2111, 3847, 229631, 246271, 262111, 786431, 1046527, 1047551
2,    5,   7,  17,   31,   41,     53,    157,    229,    239,     241,     251
2,    3,   7,  13,   23,   29,     47,     53,    101,    127,     149,     151
2,    3,   7,  11,   13,   17,     19,     23,     43,    131,     281,     311
2,    3,   5,  11,   31,   47,     71,     83,    103,    107,     151,     191
2,    3,   5,  11,   13,   17,     19,     23,     29,     37,      41,      43
2,    3,   5,   7,   13,   29,     31,     41,     43,     47,      59,      61
2,    3,   5,   7,   11,   13,     17,     19,     23,     37,      43,      47
2,    3,   5,   7,   13,   17,     31,     37,     71,     73,      79,      97
2,    3,   5,   7,   13,   17,     19,     23,     29,     31,      37,      43
2,    3,   5,   7,   11,   17,     61,     67,     71,     89,     137,     163
		

Crossrefs

Cf. A107845 (row 10), A129338.

Programs

  • PARI
    switchdigits(v, pos) = my(vt=v[pos]); v[pos]=v[pos+1]; v[pos+1]=vt; v
    decimal(v, base) = my(w=[]); for(k=0, #v-1, w=concat(w, v[#v-k]*base^k)); sum(i=1, #w, w[i])
    is(p, base) = my(db=digits(p, base)); if(vecmin(db)==1 && vecmax(db)==1, return(0)); for(k=1, #db-1, my(x=decimal(switchdigits(db, k), base)); if(!ispseudoprime(x), return(0))); 1
    array(n, k) = for(x=2, n+1, my(i=0); forprime(p=1, , if(is(p, x), print1(p, ", "); i++); if(i==k, print(""); break)))
    array(6, 10) \\ print initial 6 rows and 10 columns of array
Showing 1-4 of 4 results.