OFFSET
1,1
COMMENTS
For twin primes p,q we always have p^q == p (mod p+q) and q^p == q (mod p+q).
EXAMPLE
a(3) = 421 is a term because the next prime is 431, 421^431 == 421 (mod 852) and 431^421 == 431 (mod 852).
MAPLE
q:= 2: R:= NULL:
while p < 10^7 do
p:= q; q:= nextprime(p);
if q-p = 2 then next fi;
if q &^ p mod (p+q) = q and p &^ q mod (p+q) = p then
R:= R, p;
fi;
od:
R;
PROG
(Python)
from sympy import nextprime
A340431_list , p = [], 2
while p <= 10**10:
q = nextprime(p)
if q > p+2:
pq = p+q
if pow(q, p, pq) == q and pow(p, q, pq) == p:
A340431_list.append(p)
p = q # Chai Wah Wu, Jan 12 2021
(PARI) upto(n) = my(p=2); forprime(q = nextprime(p+1), n, if(q-p > 2, if(Mod(p, p+q)^q == p, if(Mod(q, p+q)^p == q, print1(p, ", ")))); p = q); \\ Daniel Suteu, Jan 12 2021
CROSSREFS
KEYWORD
nonn,more
AUTHOR
J. M. Bergot and Robert Israel, Jan 12 2021
EXTENSIONS
a(15)-a(17) from Daniel Suteu, Jan 12 2021
a(18)-a(22) from Chai Wah Wu, Jan 15 2021
a(23)-a(24) from Martin Ehrenstein, Jan 19 2021
STATUS
approved