OFFSET
1,1
COMMENTS
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Apr 21 2021
STATUS
approved