login
Numbers k such that k^2 +- k +- 1 is prime for all four possibilities.
2

%I #21 Jul 31 2022 17:10:41

%S 3,6,21,456,1365,2205,2451,2730,8541,18486,32199,32319,32781,45864,

%T 61215,72555,72561,82146,83259,86604,91371,95199,125334,149331,176889,

%U 182910,185535,210846,225666,226254,288420,343161,350091,403941,411501,510399,567204

%N Numbers k such that k^2 +- k +- 1 is prime for all four possibilities.

%C The only prime in this sequence is a(1) = 3.

%e 1365^2 + 1365 + 1 = 1864591,

%e 1365^2 + 1365 - 1 = 1864589,

%e 1365^2 - 1365 + 1 = 1861861, and

%e 1365^2 - 1365 - 1 = 1861859 are all prime, so 1365 is a term of this sequence.

%p q:= k-> andmap(isprime, [seq(seq(k^2+i+j, j=[k, -k]), i=[1, -1])]):

%p select(q, [3*t$t=1..200000])[]; # _Alois P. Heinz_, Feb 25 2020

%t Select[Range[568000],AllTrue[Flatten[{#^2+#+{1,-1},#^2-#+{1,-1}},1],PrimeQ]&] (* _Harvey P. Dale_, Jul 31 2022 *)

%o (Python)

%o import sympy

%o from sympy import isprime

%o {print(p) for p in range(10**6) if isprime(p**2+p+1) and isprime(p**2-p+1) and isprime(p**2+p-1) and isprime(p**2-p-1)}

%Y Numbers in the intersection of A002384, A045546, A055494, and A002328.

%Y Numbers in the intersection of A131530 and A088485.

%K nonn

%O 1,1

%A _Derek Orr_, Jan 18 2014