A245513 Smallest m such that neither of the two odd numbers that bracket n^m is a prime.
6, 7, 3, 4, 3, 3, 2, 6, 3, 2, 2, 3, 3, 6, 3, 2, 2, 4, 3, 3, 2, 1, 3, 2, 1, 4, 2, 5, 2, 2, 2, 3, 1, 3, 3, 1, 2, 3, 3, 2, 2, 3, 2, 5, 2, 1, 2, 3, 1, 2, 2, 1, 3, 3, 1, 3, 2, 2, 2, 3, 2, 6, 1, 2, 3, 1, 2, 5, 2, 4, 2, 2, 3, 3, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 2, 1, 3, 2, 1, 1, 1, 2, 2
Offset: 2
Keywords
Examples
a(4)=3 because 4^1 and 4^2 are bracketed by the odd numbers (3,5) and (15,17) and each pair contains a prime, but 4^3 is bracketed by (63,65) which are both nonprimes. a(5)=4 because 5^1, 5^2, and 5^3 are bracketed by odd pairs (3,7), (23,27) and (123,127) which all contain at least one prime. But 5^4 is bracketed by odd numbers (623,627) which are both composites.
Links
- Stanislav Sykora, Table of n, a(n) for n = 2..10000
Programs
-
Maple
f:= proc(n) local m,nm; for m from 1 do nm:= n^m; if n::odd then if not isprime(nm+2) and not isprime(nm-2) then return(m) fi elif not isprime(nm+1) and not isprime(nm-1) then return(m) fi od end proc: seq(f(n), n=2..1000); # Robert Israel, Aug 12 2014
-
Mathematica
a245513Q[n_Integer] := Module[{i}, Catch[For[i = 0, i <= 20, i++, If[EvenQ[n], If[! PrimeQ[n^i + 1] && ! PrimeQ[n^i - 1], Throw[i]], If[! PrimeQ[n^i + 2] && ! PrimeQ[n^i - 2], Throw[i]] ]]]]; a245513[n_Integer] := a245513Q /@ Range[2, n]; a245513[120] (* Michael De Vlieger, Aug 12 2014 *)
-
PARI
avector(nmax)={my(n, k, d=2, v=vector(nmax));for(n=2, #v+1, d=3-d; k=1;while(1, if((!isprime(n^k-d))&&(!isprime(n^k+d)), v[n-1]=k; break, k++)););return(v);} a=avector(10000) \\ For nmax=6000000 runs out of 1GB memory
Comments