login
A393417
a(n) = p is the smallest prime number, such that the sequence of 2n+1 consecutive prime numbers modulo n starting with p mod n is palindromic.
2
2, 3, 5, 41, 45667, 79, 1370321, 1114577, 184661011, 4178329, 1911129302867, 17213047
OFFSET
1,1
COMMENTS
An estimate of the average position of length 2*n+1 is phi(n)^n.
A block of odd length is called palindromic if the residues read the same from left to right and from right to left. For example, for n = 3, the block of 7 prime numbers [5,7,11,13,17] gives the residues modulo 3 [2,1,2,1,2,1,2], which is a palindrome.
EXAMPLE
*---*------*-------------*--------------------------------------*
| n | k | prime(k) | [prime(k), ..., prime(k+2n)] (mod n) |
*---*------*-------------*--------------------------------------*
| 1 | 1 | 2 | [0,0,0] (mod 1) |
| 2 | 2 | 3 | [1,1,1,1,1] (mod 2) |
| 3 | 3 | 5 | [2,1,2,1,2,1,2] (mod 3) |
| 4 | 13 | 41 | [1,3,3,1,3,1,3,3,1] (mod 4) |
| 5 | 4732 | 45667 | [2,3 2,1,2,2,2,1,2,3,2] (mod 5) |
| 6 | 22 | 79 | [1,5,5,1,5,1,5,1,5,1,5,5,1] (mod 6) |
MAPLE
# Function to find the first palindrome modulo n
# if the program prints "FAIL", increase the maximum value kmax.
with(ListTools):
FindLineU_simple := proc(n, P, kmax)
local R, k, i, ok;
R := [seq(P[i] mod n, i=1..kmax+2*n)];
for k from 1 to kmax do
ok := true;
for i from 0 to n do
if R[k+i] <> R[k+2*n-i] then
ok := false;
break;
end if;
end do;
if ok then
return k, [seq(R[k+i], i=0..2*n)];
end if;
end do;
return FAIL;
end proc:
# Display for n=3n=1..8
TrianglePal_1to8 := proc(kmax)
local P, n, res;
# Generate enough prime numbers
P := [seq(ithprime(i), i=1..kmax+16)]; # 2*8=16 pour le plus grand palindrome
for n from 1 to 8 do
res := FindLineU_simple(n, P, kmax);
print(n, res);
end do;
end proc:TrianglePal_1to8(10^5);
PROG
(PARI) ispal(v) = for (i=1, #v\2, if (v[i] != v[#v-i+1], return(0))); 1;
a(n) = my(v=Vecrev(primes(2*n+1)), p=prime(2*n+1)); v = apply(x->(x%n), v); while (!ispal(v), p=nextprime(p+1); v=concat(p % n, v); v=Vec(v, 2*n+1)); for(i=1, 2*n, p=precprime(p-1)); p; \\ Michel Marcus, Feb 15 2026
(Python)
from sympy import prime, nextprime
def A393417(n):
p = [prime(i) for i in range(1, n+1<<1)]
r = [q%n for q in p]
while True:
if r[:(t:=len(r)+1>>1)]==r[:-t-1:-1]: return p[0]
p = p[1:]+[m:=nextprime(p[-1])]
r = r[1:]+[m%n] # Chai Wah Wu, Feb 20 2026
CROSSREFS
Cf. A393342.
Sequence in context: A136015 A106713 A106820 * A362957 A379768 A042469
KEYWORD
nonn,hard,more
AUTHOR
Michel Lagneau, Feb 14 2026
EXTENSIONS
a(9)-a(10) from Michel Marcus, Feb 15 2026
a(11)-a(12) from Chai Wah Wu, Mar 02 2026
STATUS
approved