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 49 results. Next

A172059 Partial sums of A003459.

Original entry on oeis.org

2, 5, 10, 17, 28, 41, 58, 89, 126, 197, 270, 349, 446, 559, 690, 889, 1200, 1537, 1910, 2643, 3562, 4553, 1111111111111115664, 11112222222222222226775
Offset: 1

Views

Author

Jonathan Vos Post, Jan 24 2010

Keywords

Crossrefs

Cf. A003459.

Formula

a(n) = Sum_{i=1..n} A003459(i).

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

A004185 Arrange digits of n in increasing order, then (for n > 0) omit the zeros.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12, 22, 23, 24, 25, 26, 27, 28, 29, 3, 13, 23, 33, 34, 35, 36, 37, 38, 39, 4, 14, 24, 34, 44, 45, 46, 47, 48, 49, 5, 15, 25, 35, 45, 55, 56, 57, 58, 59, 6, 16, 26, 36, 46, 56, 66, 67, 68, 69, 7, 17, 27, 37, 47
Offset: 0

Views

Author

Keywords

Comments

Record values: A009994. - Reinhard Zumkeller, Dec 05 2009
If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in increasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 311 is both sortable and absolute, and 271 is sortable but not absolute, since its digits can be permuted to 217 = 7 * 31 or 712 = 2^3 * 89, etc. - Alonso del Arte, Oct 05 2013
The above mentioned "sortable primes" are listed in A211654, the nontrivial ones (with digits not in nondecreasing order) in A086042. - M. F. Hasler, Jul 30 2019

Examples

			a(19) = 19 because the digits are already in increasing order.
a(20) = 2 because the digits of 20 are 2 and 0, which in increasing order are 0 and 2, but since zero-padding is not allowed on the left, the zero digit is dropped and we are left with 2.
a(21) = 12 because the digits of 21 are 2 and 1, which in increasing order are 1 and 2.
		

Crossrefs

Cf. A211654 (sortable primes) and subsequence A086042 (nontrivial solutions).

Programs

  • Haskell
    import Data.List (sort)
    a004185 n = read $ sort $ show n :: Integer
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Magma
    A004185:=func; [n eq 0 select 0 else A004185(n): n in [0..57]]; // Bruno Berselli, Apr 03 2012
    
  • Maple
    A004185 := proc(n)
        local dgs;
        convert(n,base,10) ;
        dgs := sort(%,`>`) ;
        add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
    end proc:
    seq(A004185(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
  • Mathematica
    FromDigits[Sort[DeleteCases[IntegerDigits[#], 0]]]&/@Range[0, 60] (* Harvey P. Dale, Nov 29 2011 *)
  • PARI
    a(n)=fromdigits(vecsort(digits(n))) \\ Charles R Greathouse IV, Feb 06 2017
  • Python
    def A004185(n):
        return int(''.join(sorted(str(n))).replace('0','')) if n > 0 else 0 # Chai Wah Wu, Nov 10 2015
    

A004186 Arrange digits of n in decreasing order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 41, 51, 61, 71, 81, 91, 20, 21, 22, 32, 42, 52, 62, 72, 82, 92, 30, 31, 32, 33, 43, 53, 63, 73, 83, 93, 40, 41, 42, 43, 44, 54, 64, 74, 84, 94, 50, 51, 52, 53, 54, 55, 65, 75, 85, 95, 60, 61, 62, 63, 64, 65, 66, 76, 86, 96, 70, 71, 72
Offset: 0

Views

Author

Keywords

Comments

a(A009996(n)) = A009996(n). - Reinhard Zumkeller, Oct 31 2007
If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in decreasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 113 is both sortable and absolute, and 313 is sortable but not absolute since its digits can be permuted to 133 = 7 * 19. - Alonso del Arte, Oct 05 2013

Examples

			a(19) = 91 because the digits of 19 being 1 and 9, arranged in decreasing order they are 9 and 1.
a(20) = 20 because the digits are already in decreasing order.
		

Crossrefs

Programs

  • Haskell
    import Data.List (sort)
    a004186 = read . reverse . sort . show :: Integer -> Integer
    -- Reinhard Zumkeller, Aug 19 2011
    
  • Maple
    A004186 := proc(n)
        local dgs;
        convert(n,base,10) ;
        dgs := sort(%) ;
        add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
    end proc:
    seq(A004186(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
  • Mathematica
    sortDigitsDown[n_] := FromDigits@ Reverse@ Sort@ IntegerDigits@ n; Array[sortDigitsDown, 73, 0] (* Robert G. Wilson v, Aug 19 2011 *)
  • PARI
    reconstruct(m) = {local(r); r=0; for(i=1,matsize(m)[2],r=r*10+m[i]); r}
    A004186(n) = reconstruct(vecsort(digits(n),,4))
    \\ Michael B. Porter, Nov 11 2009
    
  • PARI
    a(n) = fromdigits(vecsort(digits(n), , 4)); \\ Joerg Arndt, Feb 24 2019
    
  • Python
    def a(n): return int("".join(sorted(str(n), reverse=True)))
    print([a(n) for n in range(73)]) # Michael S. Branicky, Feb 21 2021

Formula

n <= a(n) < 10n. - Charles R Greathouse IV, Aug 07 2024

Extensions

More terms from Reinhard Zumkeller, Oct 31 2007

A068652 Numbers such that every cyclic permutation is a prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 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
Offset: 1

Views

Author

Amarnath Murthy, Feb 28 2002

Keywords

Comments

See the closely related sequence A016114 for further information. - N. J. A. Sloane, May 04 2017
These numbers are sometimes called circular primes. - Tanya Khovanova, Jul 29 2024

Examples

			197 is a member as all the three cyclic permutations 197,971,719 are primes.
		

Crossrefs

Programs

  • Mathematica
    fQ[p_] := Module[{b = IntegerDigits[p]}, And @@ Table[PrimeQ[FromDigits[b = RotateLeft[b]]], {Length[b] - 1}]]; Select[Prime[Range[100000]], fQ] (* T. D. Noe, Mar 22 2012 *)
    ecppQ[n_]:=AllTrue[FromDigits/@Table[RotateLeft[IntegerDigits[n],i],{i, IntegerLength[n]}],PrimeQ]; Select[Range[400000],ecppQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Nov 25 2015 *)

Extensions

More terms from Martin Renner, Apr 10 2002

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

A258706 Absolute primes: every permutation of digits is a prime. Only the smallest representative of each permutation class is shown.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 37, 79, 113, 199, 337, 1111111111111111111, 11111111111111111111111
Offset: 1

Views

Author

N. J. A. Sloane, Jun 09 2015

Keywords

Comments

See the main entry, A003459, for further information and references cited below.
The next terms are the repunit primes (A004023) R(317), too large to be displayed here, and R(1031), too large even for a b-file. Johnson (1977) proves that subsequent terms must be of the form a*R(n) + b*10^k, with a and a+b in {1..9}, k < n, and n > 9*10^9 if b != 0. - M. F. Hasler, Jun 26 2018

Crossrefs

Cf. A003459, A004023, A004022 (subsequence of repunit primes).

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

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

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}.
Showing 1-10 of 49 results. Next