|
|
A371378
|
|
Prime numbers wherein digit values decrease, increase, and finally decrease.
|
|
1
|
|
|
1021, 1031, 1051, 1061, 1063, 1087, 1091, 1093, 1097, 2053, 2063, 2081, 2083, 2087, 2131, 2141, 2143, 2153, 2161, 3041, 3061, 3083, 3121, 3163, 3181, 3187, 3191, 3251, 3253, 3271, 4021, 4051, 4073, 4091, 4093, 4153, 4231, 4241, 4243, 4253, 4261, 4271, 4273, 4283
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
Terms must have at least 4 digits. The sequence is finite.
There are 3136837 terms, with the last being 98765432101234567987654321. - Michael S. Branicky, Mar 20 2024
|
|
LINKS
|
|
|
MAPLE
|
q:= proc(n) local i, l, s;
l, s:= convert(n, base, 10), 1;
for i to nops(l)-1 while s<5 do s:=
`if`(l[i]=l[i+1], 5,
`if`(l[i]<l[i+1], [2$2, 4$2][s], [5, 3$2, 5][s]))
od; is(s=4)
end:
|
|
MATHEMATICA
|
Select[Prime[Range[600]], SplitBy[Sign[Differences[IntegerDigits[#]]], Sign][[;; , 1]] == {-1, 1, -1} &] (* Amiram Eldar, Mar 21 2024 *)
|
|
PROG
|
(Python)
from sympy import isprime
from itertools import combinations, islice
def agen(): # generator of terms
for d in range(4, 29):
print(d)
passed = set()
for d1 in range(2, min(d-2, 11)+1):
for c1 in combinations("9876543210", d1):
for d2 in range(1, min(d-d1-1, 10)+1):
digits2 = list(map(str, range(int(c1[-1])+1, 10)))
for c2 in combinations(digits2, d2):
digits3 = list(map(str, range(int(c2[-1])-1, -1, -1)))
for c3 in combinations(digits3, d - d1 - d2):
t = int("".join(c1 + c2 + c3))
if isprime(t):
passed.add(t)
yield from sorted(passed)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,fini
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|