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-2 of 2 results.

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)))

A204844 Cyclic primes that are not absolute primes (A003459).

Original entry on oeis.org

197, 719, 971, 1193, 1931, 3119, 3779, 7793, 7937, 9311, 9377, 11939, 19391, 19937, 37199, 39119, 71993, 91193, 93719, 93911, 99371, 193939, 199933, 319993, 331999, 391939, 393919, 919393, 933199, 939193, 939391, 993319, 999331
Offset: 1

Views

Author

N. J. A. Sloane, Jan 19 2012

Keywords

Comments

Every cyclic permutation of the digits is a prime, but there exists a non-cyclic permutation of the digits that produces a composite. [Extended by Felix Fröhlich, Aug 05 2018]
The sequence is the relative complement of A317688 in A293663. - Felix Fröhlich, Aug 05 2018
Conjecture: The sequence is finite, with 999331 being the last term (cf. A293142). - Felix Fröhlich, Aug 05 2018

Examples

			197, 719 and 971 are terms of the sequence, because all three numbers are prime, each number can be obtained by cyclically permuting the digits of one of the other numbers and there exist some composites, namely 791 and 917, that can be obtained from non-cyclic permutations of the digits of those three numbers. - _Felix Fröhlich_, Aug 10 2018
		

Crossrefs

Programs

  • Mathematica
    Select[Prime@ Range@ PrimePi[10^6], Union[d = IntegerDigits[#], {1,3,7,9}] == {1, 3, 7, 9} && AllTrue[ RotateLeft[d, #] & /@ Range@ IntegerLength@ #, PrimeQ@ FromDigits@ # &] && AnyTrue[ FromDigits /@ Permutations[d], CompositeQ] &] (* Giovanni Resta, Aug 10 2018 *)
  • PARI
    eva(n) = subst(Pol(n), x, 10)
    rot(n) = if(#Str(n)==1, v=vector(1), v=vector(#n-1)); for(i=2, #n, v[i-1]=n[i]); u=vector(#n); for(i=1, #n, u[i]=n[i]); v=concat(v, u[1]); v
    is_circularprime(n) = my(d=digits(n), r=rot(d)); if(vecmin(d)==0, return(0), while(1, if(!ispseudoprime(eva(r)), return(0)); r=rot(r); if(r==d, return(1))))
    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_permutable_prime(n) = if(n < 10, return(1)); my(d=vecsort(digits(n))); while(1, if(!ispseudoprime(eva(d)), return(0)); d=next_permutation(d); if(d==0, return(1)))
    forprime(p=1, , if(is_circularprime(p) && !is_permutable_prime(p), print1(p, ", "))) \\ Felix Fröhlich, Aug 05 2018

Extensions

More terms from Felix Fröhlich, Aug 05 2018
Showing 1-2 of 2 results.