login
Smallest k such that p^p -+ k is prime, where p=prime(n).
1

%I #15 Jul 03 2023 11:45:33

%S 1,4,42,186,1302,114,1980,1638,10800,12882,12972,24324,25602,41706,

%T 19236,51864,25752,60672,108936,36468,85176,131718,45216,361710,40716,

%U 187998,450684,488784,4842,117450,479304,212610,32670,556062,354432

%N Smallest k such that p^p -+ k is prime, where p=prime(n).

%C All terms except the first term must be even numbers. - _Harvey P. Dale_, Jul 01 2023

%H Robert G. Wilson v, <a href="/A157719/b157719.txt">Table of n, a(n) for n = 1..75</a>

%e 2^2-+1=primes, 3^3=27-+4=primes, 5^5=3125-+42=3083,3167=primes, 7^7=823543-+186=823357,823729=primes, ...

%t lst={1}; Do[p=Prime[n]; pp=p^p; Do[If[PrimeQ[pp-k]&&PrimeQ[pp+k],If[pp-k<2,Break[]]; AppendTo[lst,k]; Print[p.k]; Break[]],{k,2,10^9}],{n,4!}]; lst

%t f[n_] := Block[ {pp = Prime[n]^Prime[n], k = If[n == 1, 1, 2]}, While[ !PrimeQ[pp - k] || !PrimeQ[pp + k], k += 2]; k]; lst = {}; Do[a = f@n; AppendTo[lst, a]; Print[{Prime@n, a}], {n, 100}] (* _Robert G. Wilson v_, Mar 20 2009 *)

%t skp[p_]:=Module[{k=1,p2=p^p},While[AnyTrue[p2+{k,-k},CompositeQ],k++];k]; Table[skp[p],{p,Prime[Range[40]]}] (* _Harvey P. Dale_, Jul 01 2023 *)

%K nonn

%O 1,2

%A _Vladimir Joseph Stephan Orlovsky_, Mar 04 2009

%E a(13) onwards from _Robert G. Wilson v_, Mar 20 2009