%I #29 May 02 2021 22:02:09
%S 4,20,74,347,1743,8385,44355,229952,1235489,6629026,37152645,
%T 202017712,1142393492,6333190658
%N Numbers of n-digit primes that undulate.
%C '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.
%D C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.
%H C. A. Pickover, "Wonders of Numbers, Adventures in Mathematics, Mind and Meaning," <a href="http://www.zentralblatt-math.org/zmath/en/search/?q=an:0983.00008&format=complete">Zentralblatt review</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/UndulatingNumber.html">Undulating Number.</a>
%o (Python)
%o from sympy import isprime
%o def f(w,dir):
%o if dir == 1:
%o for s in w:
%o for t in range(int(s[-1])+1,10):
%o yield s+str(t)
%o else:
%o for s in w:
%o for t in range(0,int(s[-1])):
%o yield s+str(t)
%o def A057333(n):
%o c = 0
%o for d in '123456789':
%o x = d
%o for i in range(1,n):
%o x = f(x,(-1)**i)
%o c += sum(1 for p in x if isprime(int(p)))
%o if n > 1:
%o y = d
%o for i in range(1,n):
%o y = f(y,(-1)**(i+1))
%o c += sum(1 for p in y if isprime(int(p)))
%o return c # _Chai Wah Wu_, Apr 25 2021
%Y Cf. A046075, A033619, A032758, A039944, A016073, A046076, A046077, A057332.
%K nonn,base,more
%O 1,1
%A _Patrick De Geest_, Sep 15 2000
%E Offset corrected and a(10)-a(11) from _Donovan Johnson_, Aug 08 2010
%E a(12) from _Giovanni Resta_, Feb 24 2013
%E a(2) corrected by _Chai Wah Wu_, Apr 25 2021
%E a(13)-a(14) from _Chai Wah Wu_, May 02 2021
|