OFFSET
1,1
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{i=1..n} prime(i) * prime(n+1-i), where prime(i) is the i-th prime.
G.f.: (b(x)^2)/x, where b(x) is the g.f. of A000040. - Mario C. Enriquez, Dec 13 2016
EXAMPLE
a(2)=12 because a(2) = prime(1)*prime(2) + prime(2)*prime(1) = 2*3 + 3*2 = 12.
MAPLE
A014342:=n->add(ithprime(i)*ithprime(n+1-i), i=1..n): seq(A014342(n), n=1..50); # Wesley Ivan Hurt, Dec 14 2016
MATHEMATICA
Table[Sum[Prime[i] Prime[n + 1 - i], {i, n}], {n, 40}] (* Michael De Vlieger, Dec 13 2016 *)
Table[With[{p=Prime[Range[n]]}, ListConvolve[p, p]], {n, 40}]//Flatten (* Harvey P. Dale, May 03 2018 *)
PROG
(PARI) {m=40; u=vector(m, x, prime(x)); for(n=1, m, v=vecextract(u, concat("1..", n)); w=vector(n, x, u[n+1-x]); print1(v*w~, ", "))} \\ Klaus Brockhaus, Apr 28 2004
(Haskell)
a014342 n = a014342_list !! (n-1)
a014342_list= f (tail a000040_list) [head a000040_list] 1 where
f (p:ps) qs k = sum (zipWith (*) qs $ reverse qs) :
f ps (p : qs) (k + 1)
-- Reinhard Zumkeller, Apr 07 2014, Mar 08 2012
(Magma) [&+[NthPrime(n-i+1)*NthPrime(i): i in [1..n]]: n in [1..40]]; // Bruno Berselli, Apr 12 2016
(Python)
from numpy import convolve
from sympy import prime, primerange
def aupton(terms):
p = list(primerange(2, prime(terms)+1))
return list(convolve(p, p))[:terms]
print(aupton(41)) # Michael S. Branicky, Apr 12 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
More terms from Felix Goldberg (felixg(AT)tx.technion.ac.il), Feb 01 2001
STATUS
approved