login
Smallest prime p > n + 1 where a base b exists with abs(b - p) = n such that b^(p-1) == 1 (mod p^2).
1

%I #31 Jan 30 2022 16:00:16

%S 257,23,13,229,11,13,13,599,29,109,541,29,83,4099,2011,23,47,2042851,

%T 115981

%N Smallest prime p > n + 1 where a base b exists with abs(b - p) = n such that b^(p-1) == 1 (mod p^2).

%C Smallest p = prime(i) such that at least one of p-n or p+n occurs in the i-th row of A244249.

%C a(2) = 5. a(3) and a(23) are larger than 10^8 if they exist.

%C a(3) > 10^10, a(23) > 75*10^8. - _Robert G. Wilson v_, Dec 16 2016

%H Robert G. Wilson v, <a href="/A273775/a273775_1.txt">Table of n, a(n) for n = 2..1000, or 0 if no such value is known.</a>

%e For n = 4: p = 257 satisfies b^(p-1) == 1 (mod p^2) for b = p+4 = 261, i.e., 261^256 == 1 (mod 257^2) and is the smallest such p, so a(4) = 257.

%t f[n_] := Block[{p = NextPrime[n +1]}, While[ PowerMod[p - n, p -1, p^2] != 1 && PowerMod[p + n, p -1, p^2] != 1, q = p = NextPrime@ p]; p] (* _Robert G. Wilson v_, Dec 14 2016 *)

%o (PARI) a(n) = forprime(p=n+2, , my(b=p-n, c=p+n); if(Mod(b, p^2)^(p-1)==1 || Mod(c, p^2)^(p-1)==1, return(p)))

%Y Cf. A244249.

%K nonn,hard,more

%O 4,1

%A _Felix Fröhlich_, Dec 11 2016