The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.



(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A057333 Numbers of n-digit primes that undulate. 3
4, 20, 74, 347, 1743, 8385, 44355, 229952, 1235489, 6629026, 37152645, 202017712, 1142393492, 6333190658 (list; graph; refs; listen; history; text; internal format)



'Undulate' means that the alternate digits are consistently greater than or less than the digits adjacent to them (e.g., 70769). Smoothly undulating palindromic primes (e.g., 95959) are a subset and included in the count.


C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.


Table of n, a(n) for n=1..14.

C. A. Pickover, "Wonders of Numbers, Adventures in Mathematics, Mind and Meaning," Zentralblatt review

Eric Weisstein's World of Mathematics, Undulating Number.



from sympy import isprime

def f(w, dir):

    if dir == 1:

        for s in w:

            for t in range(int(s[-1])+1, 10):

                yield s+str(t)


        for s in w:

            for t in range(0, int(s[-1])):

                yield s+str(t)

def A057333(n):

    c = 0

    for d in '123456789':

        x = d

        for i in range(1, n):

            x = f(x, (-1)**i)

        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, (-1)**(i+1))

            c += sum(1 for p in y if isprime(int(p)))

    return c # Chai Wah Wu, Apr 25 2021


Cf. A046075, A033619, A032758, A039944, A016073, A046076, A046077, A057332.

Sequence in context: A061981 A054611 A329174 * A196432 A302815 A196508

Adjacent sequences:  A057330 A057331 A057332 * A057334 A057335 A057336




Patrick De Geest, Sep 15 2000


Offset corrected and a(10)-a(11) from Donovan Johnson, Aug 08 2010

a(12) from Giovanni Resta, Feb 24 2013

a(2) corrected by Chai Wah Wu, Apr 25 2021

a(13)-a(14) from Chai Wah Wu, May 02 2021



Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 26 05:58 EDT 2021. Contains 348257 sequences. (Running on oeis4.)