OFFSET
1,2
LINKS
T. D. Noe, Table of n, a(n) for n = 1..100
FORMULA
Absolute value of Sum_{k=1..n} k^k*(-1)^(k+1). a(n) = n^n - (n-1)^(n-1) + (n-2)^(n-2) - ... - (-1)^n*1^1. - Alexander Adamchuk, Jun 30 2006
MATHEMATICA
Abs[Table[Sum[k^k*(-1)^(k+1), {k, 1, n}], {n, 1, 30}]] (* Alexander Adamchuk, Jun 30 2006 *)
RecurrenceTable[{a[1]==1, a[n]==n^n-a[n-1]}, a, {n, 20}] (* Harvey P. Dale, Jan 21 2015 *)
PROG
(Python)
from itertools import accumulate, count, islice
def A001099_gen(): # generator of terms
yield from accumulate((k**k for k in count(1)), func=lambda x, y:y-x)
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved