login
Number of n-digit undulating alternating primes.
1

%I #19 Apr 27 2021 07:54:55

%S 4,9,23,49,175,321,1189,3025,12111,28492,113409,251513,1068440,

%T 2629980,11690210,28498852,128871588,298890814,1309837146

%N Number of n-digit undulating alternating primes.

%C a(n) is the number of n-digit terms in A343590.

%C a(n) <= A057333(n).

%o (Python)

%o def f(w):

%o for s in w:

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

%o yield s+str(t)

%o def g(w):

%o for s in w:

%o for t in range(1-int(s[-1])%2,int(s[-1]),2):

%o yield s+str(t)

%o def A343676(n):

%o c = 0

%o for d in '123456789':

%o x = d

%o for i in range(1,n):

%o x = g(x) if i % 2 else f(x)

%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) if i % 2 else g(y)

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

%o return c

%Y Cf. A002385, A030144, A057333, A059168, A343590, A343675.

%K nonn,base,more

%O 1,1

%A _Chai Wah Wu_, Apr 25 2021

%E a(18)-a(19) from _Martin Ehrenstein_, Apr 27 2021