A306615 Least positive k such that 2n - p is prime where p is some prime divisor of n^k - 1, or 0 if no such k exists.
0, 0, 0, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 6, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 4, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 3, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 3, 10, 3, 3, 2, 1, 1, 2, 2, 1, 1, 1, 2, 10, 1, 1, 2, 1, 3, 2, 1, 6, 2, 2, 1, 1, 1, 1, 1, 2
Offset: 1
Keywords
Examples
a(4) = 1 because 4^1 - 1 = 3 where 3 is some prime divisor of 3 and 2*4 - 3 = 5 is prime; a(5) = 2 because 5^2 - 1 = 24 where 3 is some prime divisor of 24 and 2*5 - 3 = 7 is prime.
Crossrefs
Cf. A306261.
Programs
-
Mathematica
Table[If[n < 4, 0, Block[{k = 1}, While[NoneTrue[FactorInteger[n^k - 1][[All, 1]], PrimeQ[2 n - #] &], k++]; k]], {n, 104}] (* Michael De Vlieger, Mar 11 2019 *)
-
PARI
isok(n,k) = {my(pf=factor(n^k-1, 2*n)[,1]); for (j=1, #pf, if (isprime(2*n-pf[j]), return (1)););} a(n) = {if (n < 4, return(0)); my(k=1); while (!isok(n, k), k++); k;} \\ Michel Marcus, Mar 02 2019
Comments