OFFSET
0,3
COMMENTS
The parity of a(n) is the opposite of the parity of n.
LINKS
Robert Israel, Table of n, a(n) for n = 0..348
EXAMPLE
a(4) = (3*5*7*11) - (3+5+7+11) = 1129.
MAPLE
a:= n-> (l-> mul(i, i=l)-add(i, i=l))([ithprime(i)$i=2..n+1]):
seq(a(n), n=0..20); # Alois P. Heinz, Jul 12 2022
MATHEMATICA
FoldList[Times, 1, p = Prime[Range[2, 20]]] - Prepend[Accumulate[p], 0] (* Amiram Eldar, Jul 14 2022 *)
PROG
(Python)
from itertools import count, islice
from sympy import nextprime
def agen():
p, s, primen = 1, 0, 2
while True:
yield p - s; primen = nextprime(primen); p *= primen; s += primen
print(list(islice(agen(), 19))) # Michael S. Branicky, Jul 12 2022
(PARI) a(n) = my(vp=primes(n+1)); vecprod(vp)/2 - vecsum(vp) + 2; \\ Michel Marcus, Jul 12 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Des MacHale and Bernard Schott, Jul 12 2022
EXTENSIONS
More terms from Michael S. Branicky, Jul 12 2022
STATUS
approved