// OEIS A349321 // // "Numbers k such that k-1, k+1, 2k-1, 2k+1, 3k-1, 3k+1, 4k-1, 4k+1, 5k-1, // and 5k+1 are all primes." // // Note: the program below, when run on the Online Magma Calculator at // // http://magma.maths.usyd.edu.au/calc/ // // generates only the first three terms of A349321 before being // terminated on reaching the 120-second time limit. // Jon E. Schoenfield, Mar 21 2022 mMax:=5; // Test primality of m*k-+1 for m = 1..mMax nPrimesChk:=11; // Generate & use a list of all residues mod the nPrimesChk-th // primorial that may allow a term of this sequence Primorial:=1; R:=[0]; for iPrime in [1..nPrimesChk] do Rprev:=R; R:=[]; p:=NthPrime(iPrime); PrimorialPrev:=Primorial; Primorial*:=p; for r in Rprev do for j in [0..p-1] do rTest:=r+j*PrimorialPrev; bPossible:=true; for m in [1..mMax] do for d in [-1,1] do if (m*rTest+d) mod p eq 0 then bPossible:=false; break m; end if; end for; end for; if bPossible then R[#R+1]:=rTest; end if; end for; end for; end for; R:=Sort(R); // Array R contains all residues mod the nPrimesChk-th // primorial that may allow a term of this sequence for M in [0..172] do // enough to reach a(17)=34645262968470 (given enough time) MP:=M*Primorial; for r in R do k:=MP+r; bOK:=true; for m in [1..mMax] do for d in [-1,1] do if not IsProbablePrime(m*k+d) then bOK:=false; break m; end if; end for; end for; if bOK then k; end if; end for; end for;