OFFSET
0,3
LINKS
Robert Israel, Table of n, a(n) for n = 0..385
FORMULA
If n >= 2, a(n) = n^(1+(-1)^n)*(n^n*(n^2-n-1)+1)/(n-1)^2. - Robert Israel, Nov 15 2017
EXAMPLE
a(2) = 2^(1+1)+2*2^(2+1) = 4+16 = 20.
MAPLE
b := n->sum(m*n^(m+(-1)^n), m=1..n);
# Alternative:
f:= n -> n^(1+(-1)^n)*(n^n*(n^2-n-1)+1)/(n-1)^2:
f(0):= 0: f(1):= 1:
map(f, [$0..40]);
MATHEMATICA
Table[Sum[m*n^(m+(-1)^n), {m, 1, n}], {n, 0, 30}] (* G. C. Greubel, Oct 13 2018 *)
PROG
(PARI) a(n) = sum(m=1, n, m*n^(m+(-1)^n)); \\ Michel Marcus, Nov 15 2017
(Magma) [0] cat [(&+[m*n^(m+(-1)^n): m in [1..n]]): n in [1..30]]; // G. C. Greubel, Oct 13 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Francois Jooste (phukraut(AT)hotmail.com), Mar 10 2002
STATUS
approved