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

A032758 Undulating primes (digits alternate).

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 18181, 32323, 35353, 72727, 74747, 78787, 94949, 95959, 1212121, 1616161, 323232323, 383838383
Offset: 1

Views

Author

Patrick De Geest, May 15 1998

Keywords

Comments

Sometimes called "smoothly undulating primes", to distinguish them from A059168.

References

  • C. A. Pickover, "Keys to Infinity", Wiley 1995, p. 159,160.
  • C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.

Crossrefs

Programs

  • Mathematica
    a[n_] := DeleteDuplicates[Take[IntegerDigits[n],{1,-1,2}]]; b[n_] := DeleteDuplicates[Take[IntegerDigits[n],{2,-1,2}]]; t={}; Do[p=Prime[n]; If[p<10, AppendTo[t,p], If[Length[a[p]] == Length[b[p]] == 1 && a[p][[1]] != b[p][[1]], AppendTo[t,p]]], {n,3*10^7}]; t (* Jayanta Basu, May 04 2013 *)
  • Python
    from itertools import count, islice
    from sympy import isprime, primerange
    def agen(): # generator of terms
        yield from (p for p in primerange(2, 100) if p != 11)
        yield from (t for t in (int((A+B)*d2+A) for d2 in count(1) for A in "1379" for B in "0123456789" if A != B) if isprime(t))
    print(list(islice(agen(), 51))) # Michael S. Branicky, Jun 09 2022

Extensions

Sequence corrected by Juri-Stepan Gerasimov, Jan 28 2010
Offset corrected by Arkadiusz Wesolowski, Sep 13 2011

A343590 Undulating alternating primes.

Original entry on oeis.org

2, 3, 5, 7, 23, 29, 41, 43, 47, 61, 67, 83, 89, 101, 103, 107, 109, 163, 181, 307, 383, 503, 509, 523, 547, 563, 587, 701, 709, 727, 769, 787, 907, 929, 947, 967, 2141, 2143, 2161, 2309, 2503, 2549, 2707, 2729, 2749, 2767, 2903, 2909, 2927, 2969, 4363, 4507, 4523, 4547, 4549, 4703
Offset: 1

Views

Author

Bernard Schott, Apr 21 2021

Keywords

Comments

Equivalently, primes in which the value of the digits alternately rises or falls (undulating, A059168) and in which the parity of the digits changes in turns (alternating, A030144).
The first 17 terms are the same as A030144; then a(18) = 163 while A030144(18) = 127.

Examples

			2143 is a term as it is prime, digits 2, 1, 4 and 3 have even and odd parity alternately, and also alternately fall and rise.
		

Crossrefs

Intersection of A030144 and A059168.
A343591 is a subsequence.

Programs

  • Mathematica
    q[n_] := PrimeQ[n] && AllTrue[Differences[Sign @ Differences[(d = IntegerDigits[n])]], # != 0 &] && AllTrue[Differences @ Mod[d, 2], # != 0 &]; Select[Range[5000], q] (* Amiram Eldar, Apr 21 2021 *)
  • Python
    from sympy import sieve
    def sign(n): return (n > 0) - (n < 0)
    def ok(p):
      if p < 10: return True
      s = str(p)
      t = set(sign(int(s[i])%2-int(s[i-1])%2)*(-1)**i for i in range(1, len(s)))
      t2 = set(sign(int(s[i])-int(s[i-1]))*(-1)**i for i in range(1, len(s)))
      return (t == {1} or t == {-1}) and (t2 == {1} or t2 == {-1})
    def aupto(limit): return [p for p in sieve.primerange(1, limit+1) if ok(p)]
    print(aupto(4703)) # Michael S. Branicky, Apr 21 2021
    
  • Python
    from sympy import isprime
    def f(w,dir):
        if dir == 1:
            for s in w:
                for t in range(int(s[-1])+1,10,2):
                    yield s+str(t)
        else:
            for s in w:
                for t in range(1-int(s[-1])%2,int(s[-1]),2):
                    yield s+str(t)
    A343590_list = []
    for l in range(5):
        for d in '123456789':
            x = d
            for i in range(1,l+1):
                x = f(x,(-1)**i)
            A343590_list.extend([int(p) for p in x if isprime(int(p))])
            if l > 0:
                y = d
                for i in range(1,l+1):
                    y = f(y,(-1)**(i+1))
                A343590_list.extend([int(p) for p in y if isprime(int(p))]) # Chai Wah Wu, Apr 25 2021

A059170 Strictly undulating primes (digits alternate and differ by 1).

Original entry on oeis.org

2, 3, 5, 7, 23, 43, 67, 89, 101, 787, 32323, 78787, 1212121, 323232323, 989898989, 12121212121, 32323232323, 787878787878787878787, 787878787878787878787878787, 1212121212121212121212121212121212121212121
Offset: 1

Views

Author

N. J. A. Sloane, Feb 14 2001

Keywords

Comments

Of form ababa... with |a-b| = 1.
The next two terms have 95 and 139 digits respectively. - Jayanta Basu, May 09 2013

References

  • C. A. Pickover, "Keys to Infinity", Wiley 1995, pp. 159-160.
  • C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.

Crossrefs

Programs

  • Mathematica
    a[n_]:=DeleteDuplicates[Take[IntegerDigits[n],{1,-1,2}]]; b[n_]:=DeleteDuplicates[Take[IntegerDigits[n],{2,-1,2}]]; t={}; Do[p=Prime[n]; If[p<10, AppendTo[t,p], If[Length[a[p]] == Length[b[p]] == 1 && Abs[a[p][[1]]-b[p][[1]]] == 1, AppendTo[t,p]]], {n,10^5}]; t (* Jayanta Basu, May 08 2013 *)
    t1=Join[{2,3,5,7},Select[Range[10,100],PrimeQ[#]&&Abs[Differences[IntegerDigits[#]]]=={1}&]]; Do[a=n*10+(n-1);b=(n-1)*10+n; t1=Join[t1,Select[Table[(a*10^(2*n+1)-b)/99,{n,25}],PrimeQ]]; If[n<=7,c=n*10+(n+1);d=(n+1)*10+n;t1=Join[t1,Select[Table[(c*10^(2*n+1)-d)/99,{n,25}],PrimeQ]]],{n,1,9,2}]; Sort[t1] (* Jayanta Basu, May 09 2013 *)
     With[{c=Flatten[{#,Reverse[#]}&/@Table[{a,a+1},{a,0,8}],1]},Flatten[ Select[ Table[ FromDigits[PadRight[{},n,#]],{n,50}],PrimeQ]&/@c]]//Union (* Harvey P. Dale, Aug 20 2022 *)

Extensions

Extended by Patrick De Geest, Feb 25 2001
Offset corrected by Arkadiusz Wesolowski, Sep 13 2011

A092696 Smoothly undulating palindromic primes of the form (12*10^n-21)/99.

Original entry on oeis.org

1212121, 12121212121, 1212121212121212121212121212121212121212121
Offset: 1

Views

Author

Rick L. Shepherd, Mar 04 2004

Keywords

Comments

The De Geest link calls these smoothly undulating palindromic primes. Corresponding n are given in A062209. Equivalently, primes of the form 1212...121: Decimal digits "12" repeated k times with 1 appended (or "21" repeated k times with 1 prefixed). Corresponding k are given in A056803. The next term, a(4), has "12" repeating A056803(4) = 69 times and length A062209(4) = 2*A056803(4) + 1 = 139 decimal digits.

Crossrefs

Cf. A056803 (number of 12's (or 21's)), A062209 (corresponding decimal digit lengths).

Formula

a(n) = (4*10^A062209(n)-7)/33. - M. F. Hasler, Jul 30 2015

Extensions

Edited by M. F. Hasler, Jul 30 2015

A355301 Normal undulating numbers where "undulating" means that the alternate digits go up and down (or down and up) and "normal" means that the absolute differences between two adjacent digits may differ.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 101, 102, 103, 104, 105, 106, 107, 108, 109, 120, 121, 130, 131, 132, 140, 141, 142, 143, 150
Offset: 1

Views

Author

Bernard Schott, Jun 27 2022

Keywords

Comments

This definition comes from Patrick De Geest's link.
Other definitions for undulating are present in the OEIS (e.g., A033619, A046075).
When the absolute differences between two adjacent digits are always equal (e.g., 85858), these numbers are called smoothly undulating numbers and form a subsequence (A046075).
The definition includes the trivial 1- and 2-digit undulating numbers.
Subsequence of A043096 where the first different term is A043096(103) = 123 while a(103) = 130.
This sequence first differs from A010784 at a(92) = 101, A010784(92) = 102.
The sequence differs from A160542 (which contains 100). - R. J. Mathar, Aug 05 2022

Examples

			111 is not a term here, but A033619(102) = 111.
a(93) = 102, but 102 is not a term of A046075.
Some terms: 5276, 918230, 1053837, 263915847, 3636363636363636.
Are not terms: 1331, 594571652, 824327182.
		

Crossrefs

Cf. A059168 (subsequence of primes).
Differs from A010784, A241157, A241158.

Programs

  • Maple
    isA355301 := proc(n)
        local dgs,i,back,forw ;
        dgs := convert(n,base,10) ;
        if nops(dgs) < 2 then
            return true;
        end if;
        for i from 2 to nops(dgs)-1 do
            back := op(i,dgs) -op(i-1,dgs) ;
            forw := op(i+1,dgs) -op(i,dgs) ;
            if back*forw >= 0 then
                return false;
            end if ;
        end do:
        back := op(-1,dgs) -op(-2,dgs) ;
        if back = 0 then
            return false;
        end if ;
        return true ;
    end proc:
    A355301 := proc(n)
        option remember ;
        if n = 1 then
            0;
        else
            for a from procname(n-1)+1 do
                if isA355301(a) then
                    return a;
                end if;
            end do:
        end if;
    end proc:
    seq(A355301(n),n=1..110) ; # R. J. Mathar, Aug 05 2022
  • Mathematica
    q[n_] := AllTrue[(s = Sign[Differences[IntegerDigits[n]]]), # != 0 &] && AllTrue[Differences[s], # != 0 &]; Select[Range[0, 100], q] (* Amiram Eldar, Jun 28 2022 *)
  • PARI
    isok(m) = if (m<10, return(1)); my(d=digits(m), dd = vector(#d-1, k, sign(d[k+1]-d[k]))); if (#select(x->(x==0), dd), return(0)); my(pdd = vector(#dd-1, k, dd[k+1]*dd[k])); #select(x->(x>0), pdd) == 0; \\ Michel Marcus, Jun 30 2022

A343675 Undulating alternating palindromic primes.

Original entry on oeis.org

2, 3, 5, 7, 101, 181, 383, 727, 787, 929, 10301, 10501, 14341, 16361, 16561, 18181, 30103, 30703, 32323, 36563, 38183, 38783, 70507, 72727, 74747, 78787, 90709, 94949, 96769, 1074701, 1092901, 1212121, 1218121, 1412141, 1616161, 1658561, 1856581, 1878781, 3072703
Offset: 1

Views

Author

Chai Wah Wu, Apr 25 2021

Keywords

Comments

All terms have an odd number of decimal digits.
For n > 3, a(n) is odd and not divisible by 5.
Intersection of A002385, A030144 and A059168.
Subsequence of A343590.

Examples

			16361 is a term as it is a palindromic prime, the digits 1, 6, 3, 6 and 1 have odd and even parity alternately, and also alternately rise and fall.
		

Crossrefs

Programs

  • Mathematica
    Union@Flatten[{{2,3,5,7},Array[Select[FromDigits/@Riffle@@@Tuples[{Tuples[{1,3,5,7,9},#],Tuples[{0,2,4,6,8},#-1]}],(s=Union@Partition[Sign@Differences@IntegerDigits@#,2];(s=={{1,-1}}||s=={{-1,1}})&&PrimeQ@#&&PalindromeQ@#)&]&,4]}] (* Giorgos Kalogeropoulos, Apr 26 2021 *)
  • Python
    from sympy import isprime
    def f(w):
        for s in w:
            for t in range(int(s[-1])+1,10,2):
                yield s+str(t)
    def g(w):
        for s in w:
            for t in range(1-int(s[-1])%2,int(s[-1]),2):
                yield s+str(t)
    A343675_list = [2,3,5,7]
    for l in range(1,9):
        for d in '1379':
            x = d
            for i in range(1,l+1):
                x = g(x) if i % 2 else f(x)
            A343675_list.extend([int(p+p[-2::-1]) for p in x if isprime(int(p+p[-2::-1]))])
            y = d
            for i in range(1,l+1):
                y = f(y) if i % 2 else g(y)
            A343675_list.extend([int(p+p[-2::-1]) for p in y if isprime(int(p+p[-2::-1]))])

A343676 Number of n-digit undulating alternating primes.

Original entry on oeis.org

4, 9, 23, 49, 175, 321, 1189, 3025, 12111, 28492, 113409, 251513, 1068440, 2629980, 11690210, 28498852, 128871588, 298890814, 1309837146
Offset: 1

Views

Author

Chai Wah Wu, Apr 25 2021

Keywords

Comments

a(n) is the number of n-digit terms in A343590.
a(n) <= A057333(n).

Crossrefs

Programs

  • Python
    def f(w):
        for s in w:
            for t in range(int(s[-1])+1,10,2):
                yield s+str(t)
    def g(w):
        for s in w:
            for t in range(1-int(s[-1])%2,int(s[-1]),2):
                yield s+str(t)
    def A343676(n):
        c = 0
        for d in '123456789':
            x = d
            for i in range(1,n):
                x = g(x) if i % 2 else f(x)
            c += sum(1 for p in x if isprime(int(p)))
            if n > 1:
                y = d
                for i in range(1,n):
                    y = f(y) if i % 2 else g(y)
                c += sum(1 for p in y if isprime(int(p)))
        return c

Extensions

a(18)-a(19) from Martin Ehrenstein, Apr 27 2021

A343677 Number of (2n+1)-digit undulating alternating palindromic primes.

Original entry on oeis.org

4, 6, 19, 34, 100, 241, 697, 1779, 6590, 16585, 57237, 179291, 591325, 1707010, 6520756, 18271423, 65212230, 210339179, 706823539
Offset: 0

Views

Author

Chai Wah Wu, Apr 25 2021

Keywords

Comments

a(n) is the number of (2n+1)-digit terms in A343675.
a(n) <= A057332(n).

Crossrefs

Programs

  • Python
    from sympy import isprime
    def f(w):
        for s in w:
            for t in range(int(s[-1])+1,10,2):
                yield s+str(t)
    def g(w):
        for s in w:
            for t in range(1-int(s[-1])%2,int(s[-1]),2):
                yield s+str(t)
    def A343677(n):
        if n == 0:
            return 4
        c = 0
        for d in '1379':
            x = d
            for i in range(1,n+1):
                x = g(x) if i % 2 else f(x)
            c += sum(1 for p in x if isprime(int(p+p[-2::-1])))
            y = d
            for i in range(1,n+1):
                y = f(y) if i % 2 else g(y)
            c += sum(1 for p in y if isprime(int(p+p[-2::-1])))
        return c

Extensions

a(17)-a(18) from Chai Wah Wu, May 02 2021

A309488 Primes whose decimal expansion is of the form d_1+0+d_2+0+d_3+0+...+0+d_k where d_i are digits with 1 <= d_i <= 9, k > 1 and + stands for concatenation.

Original entry on oeis.org

101, 103, 107, 109, 307, 401, 409, 503, 509, 601, 607, 701, 709, 809, 907, 10103, 10301, 10303, 10501, 10601, 10607, 10709, 10903, 10909, 20101, 20107, 20201, 20407, 20507, 20509, 20707, 20807, 20809, 20903, 30103, 30109, 30203, 30307, 30403, 30509, 30703, 30707, 30803, 30809
Offset: 1

Views

Author

Bernard Schott, Aug 04 2019

Keywords

Comments

The terms of this sequence have necessarily an odd number >= 3 of digits.
There is only one term whose digits > 0 are all equal: 101.
The only cyclops primes (A134809) of this sequence are the first 15 terms from 101 to 907.
The first palindromes of this sequence are 101, 10301, 10501, 10601, 30103, 30203, 30403, 30703, 30803, ...
Intersection with A309101 = {503, 10103, 10303, 10903, ...}.

Examples

			103 is the smallest term with two distinct digits > 0.
10607 is the smallest term with three distinct digits > 0.
		

Crossrefs

Subsequence of A059168 (undulating primes).

Programs

  • Magma
    sol:=[]; m:=1; for p in PrimesInInterval(101,50000) do  v:=Reverse(Intseq(p)); test:=0; for u in [1..#v-1] do if u mod 2 eq 0 and v[u] eq 0 and v[u+1] ne 0 then test:=test+1; end if; end for; if test eq (#v-1)/2 then sol[m]:=p; m:=m+1; end if; end for; sol; // Marius A. Burtea, Aug 04 2019
    
  • Mathematica
    aQ[n_] := PrimeQ[n] && OddQ[(m = Length[(d = IntegerDigits[n])])] && Flatten@Position[d, ?(# == 0 &)] == Range[2, m, 2]; Select[Range[100, 31000], aQ] (* _Amiram Eldar, Aug 04 2019 *)
  • PARI
    eva(n) = subst(Pol(n), x, 10)
    f(n) = my(d=digits(n)); eva(vector(2*#d-1, k, if (k%2, d[1+k\2]))) \\ from Michel Marcus
    terms(n) = my(i=0); for(k=10, oo, if(i>=n, break); if(vecmin(digits(k)) > 0, my(iz=f(k)); if(ispseudoprime(iz), print1(iz, ", "); i++)))
    /* Print initial 40 terms as follows: */
    terms(40) \\ Felix Fröhlich, Aug 08 2019
Showing 1-9 of 9 results.