OFFSET
1,2
COMMENTS
Except for the initial term, a(n)>=2 because in the interval 2n-1 of odd numbers there are always at least two primes.
For n>2, this is the same as the number of primes between n^2-n and n^2+n, which is the sum of A089610 and A094189. - T. D. Noe, Sep 16 2008
From Pierre CAMI, Sep 03 2014: (Start)
For n>1 a(n)~floor(1/2 + n/log(n)).
The number of primes < n^2 is ~ n^2/2/log(n) by the prime number theorem, as a(n) ~ floor(1/2 + n/log(n)) we have:
n^2/2/log(n) ~ 1 + floor(1/2 + 2/log(2)) + floor(1/2 + 3/log(3)) + floor(1/2 + 4/log(4)) + ... + floor(1/2 + (n-1)/log(n-1)) + floor(1/2 + n/log(n)).
For n=16000 the number of primes < n^2 is 13991985, the sum: 1 + floor(1/2 + 2/log(2)) + floor(1/2 + 3/log(3)) + floor(1/2 + 4/log(4))+ ... + floor(1/2 + (n-1)/log(n-1)) + floor(1/2 + n/log(n)) is 13991101 and (n^2)/(2*log(n)) is 13222671.
So between n^2+n and n^2+3*n there are n odd numbers and ~floor(1/2 + n/log(n)) prime numbers.
The twin primes are of the form T1=n^2+n-1 and T2=n^2+n+1, or n^2+n+T1 and n^2+n+T2 with T1<=2*n-1, or n^2+n+P and n^2+n+P(-2 or +2) with P prime <=2*n-1.
(End)
LINKS
T. D. Noe, Table of n, a(n) for n=1..10000
EXAMPLE
Triangle begins:
1: 1 -> 0 primes,
2: 3,5 -> 2 primes,
3: 7,9,11 -> 2 primes,
4: 13,15,17,19 -> 3 primes.
MAPLE
seq(numtheory:-pi(n^2+n-1)-numtheory:-pi(n^2-n), n=1..100); # Robert Israel, Sep 03 2014
MATHEMATICA
f[n_] := PrimePi[n^2 + n - 1] - PrimePi[n^2 - n]; Table[f[n], {n, 81}] (* Ray Chandler, Jul 26 2005 *)
PROG
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Giovanni Teofilatto, Jul 25 2005
EXTENSIONS
Edited and extended by Ray Chandler, Jul 26 2005
STATUS
approved