OFFSET
1,1
COMMENTS
We list the twin primes in staircase fashion as follows.
3
5_5
__7_11
____13_17
_______19_29
__________31_41
_____________.._..
________________tu(n)_tl(n)
______________________tu(n+1)
...
where tl(n) = n-th lower twin prime, tu(n) = n-th upper twin prime. Then a(n) = tl(n) + tu(n) + tl(n+1).
FORMULA
PROG
(PARI) g(n) = for(x=1, n, y=twinu(x)+twinl(x) + twinl(x+1); print1(y", ")) twinl(n) = / *The n-th lower twin prime. */ { local(c, x); c=0; x=1; while(c<n, if(ispseudoprime(prime(x)+2), c++); x++; ); return(prime(x-1)) } twinu(n) = /* The n-th upper twin prime. */ { local(c, x); c=0; x=1; while(c<n, if(isprime(prime(x)+2), c++); x++; ); return(prime(x)) }
CROSSREFS
KEYWORD
nonn
AUTHOR
Cino Hilliard, Dec 02 2007
STATUS
approved