OFFSET
0,2
COMMENTS
For n = 0 and n = 1, no k > 0 can yield a positive prime, the given values are the smallest to yield the opposite of a positive prime: M(0)^2 - 2*1 = 0 - 2 = -2 and M(1)^2 - 2*2 = 1 - 4 = -3.
LINKS
Robert Israel, Table of n, a(n) for n = 0..1000
FORMULA
a(n) = 1 for n=0 or n in A091515.
EXAMPLE
For n = 2, M(2) = 2^2 - 1 = 3 and 3*3 - 2k = 7 is a prime for k=1, thus a(2) = 1.
For n = 3, M(3) = 2^3 - 1 = 7 and 7*7 - 2k = 47 is a prime for k=1, thus a(3) = 1.
For n = 4, M(4) = 2^4 - 1 = 15 and 15*15 - 2k = 223 is a prime for k=1, thus a(4) = 1.
For n = 5, M(5) = 2^5 - 1 = 31 and 31*31 - 2k = 953 is prime for k=4 and no smaller k, thus a(5) = 4.
MAPLE
f:= proc(n) local r;
r:= (2^n-1)^2;
(r - prevprime(r))/2
end proc:
f(0):=1: f(1):= 2:
map(f, [$0..100]); # Robert Israel, Apr 02 2020
MATHEMATICA
f[n_] := Module[{r = (2^n - 1)^2}, (r - NextPrime[r, -1])/2 ];
f[0] = 1; f[1] = 2;
f /@ Range[0, 100] (* Jean-François Alcover, Jul 28 2020, after Robert Israel *)
PROG
(PARI) a(n)={n>1&&for(k=1, 9e9, ispseudoprime((2^n-1)^2-2*k)&&return(k)); n+1}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Jul 30 2015
STATUS
approved