|
|
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)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
'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.
|
|
REFERENCES
|
C. A. Pickover, "Wonders of Numbers", Oxford New York 2001, Chapter 52, pp. 123-124, 316-317.
|
|
LINKS
|
C. A. Pickover, "Wonders of Numbers, Adventures in Mathematics, Mind and Meaning," Zentralblatt review
|
|
PROG
|
(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):
yield s+str(t)
else:
for s in w:
for t in range(0, int(s[-1])):
yield s+str(t)
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)))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,more
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|