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-10 of 22 results. Next

A270083 Near-miss circular primes: Primes p where all but one of the numbers obtained by cyclically permuting the digits of p are prime.

Original entry on oeis.org

19, 23, 29, 41, 43, 47, 53, 59, 61, 67, 83, 89, 101, 103, 107, 127, 149, 157, 163, 173, 181, 191, 271, 277, 307, 313, 317, 331, 359, 367, 379, 397, 419, 479, 491, 571, 577, 593, 617, 631, 673, 701, 709, 727, 739, 757, 761, 787, 797, 811, 839, 877, 907, 911
Offset: 1

Views

Author

Felix Fröhlich, Mar 10 2016

Keywords

Comments

Prime p is a term of the sequence iff A262988(p) = A055642(p) - 1.
If a(512) exists, it is larger than 10^16. - Giovanni Resta, Apr 27 2017
If one of the digits is even or 5, the miss occurs when that digit is permuted to the ones place. Avoiding that simple obstruction, this sequence intersected with A091633 is 19, 173, 191, 313, 317, 331, 379, 397, 739, 797, 911, 937, 977, 1319, 1777, 1913, 1979, 1993, 3191, 3373, 3719, 3733, 3793, ... . Is this an infinite subsequence? - Danny Rorabaugh, May 15 2017

Crossrefs

Programs

A293663 Circular primes that are not repunits.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 197, 199, 311, 337, 373, 719, 733, 919, 971, 991, 1193, 1931, 3119, 3779, 7793, 7937, 9311, 9377, 11939, 19391, 19937, 37199, 39119, 71993, 91193, 93719, 93911, 99371, 193939, 199933, 319993, 331999, 391939
Offset: 1

Views

Author

Felix Fröhlich, Dec 30 2017

Keywords

Comments

Relative complement of A004022 in A068652.
Conjecture: The sequence is finite.
From Michael De Vlieger, Dec 30 2017: (Start)
Primes > 5 in this sequence must only have digits that are in the reduced residue system modulo 10, i.e., {1, 3, 7, 9}.
There are 54 terms that have 6 or fewer decimal digits, the largest of which is 999331.
a(55) must be larger than 10^11. (End) [Corrected by Felix Fröhlich, Mar 15 + 24 2019]
From Felix Fröhlich, Mar 16 2019: (Start)
a(55) > 10^23 if it exists (cf. De Geest link).
Numbers k such that A262988(k) = A055642(k). (End)

Examples

			The numbers resulting from cyclic permutations of the digits of 1193 are 1931, 9311 and 3119, respectively and all those numbers are prime, so 1193, 1931, 3119 and 9311 are terms of the sequence.
		

Crossrefs

Cf. base-b nonrepunit circular primes: A293657 (b=4), A293658 (b=5), A293659 (b=6), A293660 (b=7), A293661 (b=8), A293662 (b=9).

Programs

  • Mathematica
    Select[Prime@ Range[10^5], Function[w, And[AllTrue[Array[FromDigits@ RotateRight[w, #] &, Length@ w - 1], PrimeQ], Union@ w != {1} ]]@ IntegerDigits@ # &] (* or *)
    Select[Flatten@ Array[FromDigits /@ Most@ Rest@ Tuples[{1, 3, 7, 9}, #] &, 9, 2], Function[w, And[AllTrue[Array[FromDigits@ RotateRight[w, #] &, Length@ w], PrimeQ], Union@ w != {1} ]]@ IntegerDigits@ # &] (* Michael De Vlieger, Dec 30 2017 *)
  • 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(p) = my(d=digits(p), 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))))
    forprime(p=1, , if(vecmax(digits(p)) > 1, if(is_circularprime(p), print1(p, ", "))))
    
  • PARI
    /* The following is a much faster program that only tests numbers whose decimal expansion consists of digits from the set {1, 3, 7, 9}. */
    eva(n) = subst(Pol(n), x, 10)
    next_v(vec) = my(k=#vec); if(vecmin(vec)==9, vec=concat(vector(#vec, t, 1), [3]); return(vec)); while(k > 0, if(vec[k]==9, vec[k]=1, if(vec[k]==3, vec[k]=7; return(vec), vec[k]=vec[k]+2, return(vec))); k--)
    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
    search(n) = my(d=digits(n), e=[], ed=0); while(1, e=rot(d); while(1, if(!ispseudoprime(eva(e)), break, e=rot(e); if(e==d && ispseudoprime(eva(e)), print1(eva(d), ", "); break))); d=next_v(d))
    searchfrom(n) = if(n < 12, forprime(p=n, 10, print1(p, ", ")); search(13), my(d=digits(n)); for(k=1, #d, if(d[k]%2==0, d[k]++, if(d[k]==5, d[k]=7))); search(eva(d)))
    /* Start a search from 1 upwards as follows: */
    searchfrom(1) \\ Felix Fröhlich, Mar 23 2019

A293142 Largest nonrepunit base-n circular prime (conjectured).

Original entry on oeis.org

7, 1013, 3121, 211
Offset: 3

Views

Author

Felix Fröhlich, Oct 01 2017

Keywords

Comments

A circular prime is a prime where all numbers produced by cyclic permutations of the digits are also prime.
No nonrepunit circular prime exists in base 2, since any nonrepunit prime contains at least one 0 digit in its base-2 representation that yields an even number and thus a composite when permuted to the least significant place, so the offset of the sequence is 3.
a(3)-a(6) were found via a brute-force approach searching from the largest prime with 12 base-n digits backwards. The number of base-n digits in a(n) for n = 3, 4, 5, 6 is 2, 5, 5, 3, respectively. Since this is much shorter than 12 digits, it is conjectured that the terms are the maximal circular primes for those bases. This also verifies that no circular primes with a length between A055642(a(n)) and 13 digits exist in bases 3, 4, 5 and 6.
Candidates for a(7), a(8) and a(9) are 13143449029, 16244441 and 4717103, respectively.
a(10) is probably 999331. If not, it must have more than 23 digits (cf. De Geest link).

Examples

			1013 written in base 4 is 33311. The base-4 numbers 33311, 33113, 31133, 11333, 13331 written in base 10 are 1013, 983, 863, 383 and 509, respectively. All those base-10 numbers are prime and since there is no larger prime up to 12 base-4 digits where all cyclic permutations of base-4 digits are primes, 1013 is conjectured to be the largest nonrepunit circular prime in base 4.
		

Crossrefs

Cf. base-b nonrepunit circular primes: A293657 (b=4), A293658 (b=5), A293659 (b=6), A293660 (b=7), A293661 (b=8), A293662 (b=9), A293663 (b=10).

Programs

  • PARI
    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
    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_circularprime(p, base) = my(db=digits(p, base), r=rot(db), i=0); if(vecmin(db)==0, return(0), while(1, dec=decimal(r, base); if(!ispseudoprime(dec), return(0)); r=rot(r); if(r==db, return(1))))
    a(base, maxlength) = my(p=precprime(base^maxlength)); while(p > 2, if(vecmin(digits(p, base))!=vecmax(digits(p, base)), if(is_circularprime(p, base), return(p))); p=precprime(p-1))
    for(n=3, 6, print1(a(n, 12), ", ")) \\ start searching a(n) from largest prime with 12 base-n digits backwards

A016114 The smallest representative in a cycle of circular primes, where circular primes are numbers that remain prime under cyclic shifts of digits.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 37, 79, 113, 197, 199, 337, 1193, 3779, 11939, 19937, 193939, 199933, 1111111111111111111, 11111111111111111111111
Offset: 1

Views

Author

Keywords

Comments

The next repunit that is prime has 317 digits, all ones. See A004023. - Harvey P. Dale, Mar 22 2012
Only the smallest member of the cyclic shift is listed. See A068652 for all members. - Chai Wah Wu, Nov 09 2015
It is highly likely that all circular primes not on the list above are repunits (see Caldwell link). - Ray Chandler, May 04 2017
Circular primes are A068652 (numbers that remain prime under cyclic shifts of digits). - Tanya Khovanova, Jul 29 2024

Crossrefs

Sequence includes all prime repunits (A004023). Cf. A003459, A293663.
For a sequence listing all the prime-yielding cyclic permutations see A068652.

Programs

  • Mathematica
    circularPrimeQ[p_] := Module[{d = IntegerDigits[p], ps}, ps = Table[FromDigits[d = RotateLeft[d]], {Length[d]}]; If[p > Min[ps], False, And @@ PrimeQ[ps]]]; Select[Prime[Range[100000]], circularPrimeQ] (* T. D. Noe, Mar 22 2012 *)
    Union[Select[Union/@((FromDigits/@Table[RotateRight[IntegerDigits[#],n],{n,IntegerLength[ #]}])&/@Prime[Range[20000]]),AllTrue[#,PrimeQ]&]][[All,1]] (* The program generates the first 19 terms of the sequence. *) (* Harvey P. Dale, Nov 14 2022 *)

Extensions

One more term from Lekraj Beedassy, Nov 07 2002
Name edited by Tanya Khovanova, Jul 29 2024

A068654 Prime numbers such that every cyclic permutation (other than the number itself) is composite.

Original entry on oeis.org

19, 23, 29, 41, 43, 47, 53, 59, 61, 67, 83, 89, 109, 137, 139, 151, 167, 179, 193, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 281, 283, 293, 347, 349, 353, 383, 389, 401, 409, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 487, 499, 503, 509
Offset: 1

Views

Author

Amarnath Murthy, Feb 28 2002

Keywords

Examples

			167 is a member as the two cyclic permutations other than the number itself i.e. 671 and 716 are composite.
		

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[100]],Union[PrimeQ[FromDigits/@Table[ RotateRight[ IntegerDigits[#],i],{i,IntegerLength[#]-1}]]]=={False}&] (* Harvey P. Dale, Dec 08 2012 *)

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jun 21 2002

A068653 Composite numbers such that every cyclic shift (other than the number itself) gives a prime.

Original entry on oeis.org

14, 16, 20, 30, 32, 34, 35, 38, 50, 70, 74, 76, 91, 92, 95, 98, 110, 118, 119, 133, 170, 176, 194, 310, 316, 398, 710, 712, 715, 730, 731, 736, 772, 775, 778, 779, 790, 793, 794, 914, 935, 970, 973, 1118, 1130, 1195, 1312, 1336, 1370, 1774, 1937, 3110, 3112
Offset: 1

Views

Author

Amarnath Murthy, Feb 28 2002

Keywords

Comments

Single-digit numbers are excluded. There are only 144 terms up through 10 million. - Harvey P. Dale, Sep 12 2014

Examples

			176 is a term as the two cyclic shifts other than the number itself, 761 and 617, are primes.
		

Crossrefs

Programs

  • Mathematica
    LiQ[n_] := Module[{s=0}, li1=IntegerDigits[n]; k=Length[li1]; t={li1}; Do[li1=RotateLeft[li1]; AppendTo[t,li1], {i,k-1}]; If[Length[Select[Table[FromDigits[p],{p,t}], PrimeQ]] == k-1, s=1]; s]; t1={}; Do[If[!PrimeQ[i] && LiQ[i]==1, AppendTo[t1,i]], {i,10,3112}]; t1 (* Jayanta Basu, May 03 2013 *)
    cppQ[n_]:=Module[{c=FromDigits/@NestList[RotateLeft[#]&,IntegerDigits[n], IntegerLength[ n]-1]},CompositeQ[c[[1]]]&&AllTrue[Rest[c],PrimeQ]]; Select[ Range[10,5000],cppQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Sep 12 2014 *)
  • Python
    from itertools import product
    from sympy import isprime
    A068653_list = []
    for l in range(1,9):
        for m in product(('1379' if l > 1 else '123579'),repeat=l):
            for d in '0123456789':
                s = ''.join(m)+d
                n = int(s)
                if not isprime(n):
                    for k in range(len(s)-1):
                        s = s[1:]+s[0]
                        if not isprime(int(s)):
                            break
                    else:
                        A068653_list.append(n) # Chai Wah Wu, May 06 2017

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jun 21 2002

A262988 Number of distinct primes, including n if prime, obtained by cyclically shifting the digits of n.

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 2, 1, 0, 1, 1, 0, 2, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 0, 2, 1, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0
Offset: 1

Views

Author

Felix Fröhlich, Oct 06 2015

Keywords

Comments

First differs from A039999 at n = 103.
Differs from A061264 iff n is a term of A004022.
a(n) = A055642(n) iff n is a term of A068652, except when n is also in A004022.

Examples

			a(1013) = 2, because of the four cyclic permutations of the digits of 1013 (1013, 131, 1310, 3101) two, namely 1013 and 131, are prime and those two primes are distinct.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{len = IntegerLength@ n, s = {n}}, Do[AppendTo[s, FromDigits@ RotateRight@ IntegerDigits@ s[[k - 1]]], {k, 2, len}]; DeleteDuplicates@ Select[s, PrimeQ]]; Array[ Length@ f@ # &, {87}] (* Michael De Vlieger, Oct 07 2015 *)
  • PARI
    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
    eva(n) = x=0; for(k=1, #n, x=x+(n[k]*10^(#n-k))); x
    a(n) = i=0; r=rot(digits(n)); while(r!=digits(n), if(ispseudoprime(eva(r)), i++); r=rot(r)); if(ispseudoprime(eva(r)), i++); i

A085298 a(n) is the smallest exponent x such that prime(n)^x when reversed is a prime.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 2, 8, 7, 1, 1, 2, 5, 15, 10, 12, 4, 39, 1, 1, 1, 11, 2, 1, 1, 10, 1, 23, 1, 5, 1, 243, 2, 1, 1, 1, 23, 1, 34, 1, 1, 1, 2, 58, 1, 3, 9, 166, 17, 68, 8, 8, 3, 7, 5, 5, 2, 2, 2, 61, 11, 97, 1, 1, 10, 2, 1, 1, 41, 1, 1, 66, 1, 5, 1, 1, 2, 2, 8, 40, 2, 8, 19, 2, 2, 723
Offset: 1

Views

Author

Labos Elemer, Jun 24 2003

Keywords

Comments

It is conjectured that for every n such exponent exists.

Examples

			a(n)=1 means that rev(prime(n)) is prime i.e. prime(n) is in A007500;
a(n)=2 means that rev(prime(n)^2) is prime but rev(prime(n)) is not, like n=8:p=19 and 91 is not a prime but rev[19^2]=rev[361]=163 is a prime;
For n, the first k exponent providing rev(prime(n)^k) prime can be quite large, like at n=87: rev(p(87)^723)=rev(449^723) is the first [probably] prime has 1918 decimal digits: 948......573.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local k, p; p:= ithprime(n); for k while not isprime((s->
          parse(cat(seq(s[-i], i=1..length(s)))))(""||(p^k))) do od; k
        end:
    seq(a(n), n=1..50);  # Alois P. Heinz, Sep 04 2019
  • Mathematica
    a[n_] := Block[{k = 1}, While[! PrimeQ@ FromDigits@ Reverse@ IntegerDigits[ Prime[n]^k], k++]; k]; Array[a, 87] (* Giovanni Resta, Sep 04 2019 *)
  • PARI
    a(n) = {my(x=1, p=prime(n)); while (!ispseudoprime(fromdigits(Vecrev(digits(p^x)))), x++); x;} \\ Michel Marcus, Sep 04 2019

Formula

a(n) = Min{x; reversed(prime(n)^x) is a prime}.

A107845 Transposable-digit primes: Primes such that if any single pair of adjacent digits is transposed the result is a prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 137, 179, 199, 277, 311, 331, 337, 373, 379, 397, 419, 491, 577, 613, 733, 811, 877, 911, 919, 977, 991, 1013, 1031, 1091, 1117, 1213, 1231, 1579, 1777, 1811, 1999, 2113, 2131, 2399, 2411, 2677, 2699, 2719
Offset: 1

Views

Author

Rick L. Shepherd, May 24 2005

Keywords

Comments

A single transposition error (of decimal digits) when recording or communicating such a prime still results in a prime (possibly the same prime). A003459 and A004022 (its subsequence) are subsequences. A003459 is also a subsequence of A068652.

Examples

			137 is a term because it is prime and 173 and 317 are also prime.
173 is not a term because 713 is not prime (even though 173 and 137 are prime). {Hence none of 137,173,317,371,713,731 is a term of A003459.}
3119 is a term because it is prime and 1319 and 3191 are primes.
As 3119, 1193, 1931 and 9311 are all prime, 3119 is also a term of A068652.
Finally, although 1913 is also prime, neither 1139, 1391, 3911, 9113, nor 9131 is prime so 3119's twelve total permutations are not terms of A003459.
		

Crossrefs

Cf. A003459 (absolute primes), A004022 (repunit primes), A068652 (every cyclic permutation is prime).

Programs

  • Mathematica
    swap[lst_List, i_Integer] := Block[{lsu = lst}, ReplacePart[ lsu, {i -> lsu[[i + 1]], i + 1 -> lsu[[i]]}]]; fQ[n_] := Block[{id = IntegerDigits@ n, l = Floor@ Log10@ n}, And @@ Table[ PrimeQ@ FromDigits@ swap[id, j], {j, l}] == True]; Select[ Prime@ Range@ 500, fQ] (* Robert G. Wilson v, Nov 29 2014 *)
  • PARI
    eva(n) = subst(Pol(n), x, 10)
    switchdigits(v, pos) = my(vt=v[pos]); v[pos]=v[pos+1]; v[pos+1]=vt; v
    is(n) = my(d=digits(n)); for(k=1, #d-1, if(!ispseudoprime(eva(switchdigits(d, k))), return(0))); 1
    forprime(p=1, , if(is(p), print1(p, ", "))) \\ Felix Fröhlich, Sep 21 2019

Extensions

Offset changed from 0 to 1 by Felix Fröhlich, Sep 21 2019

A108388 Transmutable primes: Primes with distinct digits d_i, i=1,m (2<=m<=4) such that simultaneously exchanging all occurrences of any one pair (d_i,d_j), i<>j results in a prime.

Original entry on oeis.org

13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 179, 191, 199, 313, 331, 337, 773, 911, 919, 1171, 1933, 3391, 7717, 9311, 11113, 11119, 11177, 11717, 11933, 33199, 33331, 77171, 77711, 77713, 79999, 97777, 99991, 113111, 131111, 131113, 131171, 131311
Offset: 1

Views

Author

Rick L. Shepherd, Jun 02 2005

Keywords

Comments

a(n) is a term iff a(n) is prime and binomial(m,2) 'transmutations' (see example) of a(n) are different primes. A083983 is the subsequence for m=2: one transmutation (The author of A083983, Amarnath Murthy, calls the result of such a digit-exchange a self-complement. {Because I didn't know until afterwards that this sequence was a generalization of A083983 and as this generalization always leaves some digits unchanged for m>2, I've chosen different terminology.}). A108389 ({1,3,7,9}) is the subsequence for m=4: six transmutations. Each a(n) corresponding to m=3 (depending upon its set of distinct digits) and having three transmutations is also a member of A108382 ({1,3,7}), A108383 ({1,3,9}), A108384 ({1,7,9}), or A108385 ({3,7,9}). The condition m>=2 only eliminates the repunit (A004022) and single-digit primes. The condition m<=4 is not a restriction because if there were more distinct digits, they would include even digits or the digit 5, in either case transmuting into a composite number. Some terms such as 1933 are reversible primes ("Emirps": A006567) and the reverse is also transmutable. The transmutable prime 3391933 has three distinct digits and is also a palindromic prime (A002385). The smallest transmutable prime having four distinct digits is A108389(0) = 133999337137 (12 digits).

Examples

			179 is a term because it is prime and its three transmutations are all prime:
exchanging ('transmuting') 1 and 7: 179 ==> 719 (prime),
exchanging 1 and 9: 179 ==> 971 (prime) and
exchanging 7 and 9: 179 ==> 197 (prime).
(As 791 and 917 are not prime, 179 is not a term of A068652 or A003459 also.).
Similarly, 1317713 is transmutable:
exchanging all 1's and 3s: 1317713 ==> 3137731 (prime),
exchanging all 1's and 7s: 1317713 ==> 7371173 (prime) and
exchanging all 3s and 7s: 1317713 ==> 1713317 (prime).
		

Crossrefs

Cf. A108382, A108383, A108384, A108385, A108386, A108389 (transmutable primes with four distinct digits), A083983 (transmutable primes with two distinct digits), A108387 (doubly-transmutable primes), A006567 (reversible primes), A002385 (palindromic primes), A068652 (every cyclic permutation is prime), A003459 (absolute primes).

Programs

  • Python
    from gmpy2 import is_prime
    from itertools import combinations, count, islice, product
    def agen(): # generator of terms
        for d in count(2):
            for p in product("1379", repeat=d):
                p, s = "".join(p), sorted(set(p))
                if len(s) == 1: continue
                if is_prime(t:=int(p)):
                    if all(is_prime(int(p.translate({ord(c):ord(d), ord(d):ord(c)}))) for c, d in combinations(s, 2)):
                        yield t
    print(list(islice(agen(), 50))) # Michael S. Branicky, Dec 15 2023
Showing 1-10 of 22 results. Next