login
A215096
a(0)=0, a(1)=1, a(n) = n! - a(n-2).
4
0, 1, 2, 5, 22, 115, 698, 4925, 39622, 357955, 3589178, 39558845, 475412422, 6187461955, 86702878778, 1301486906045, 20836087009222, 354385941189955, 6381537618718778, 121290714467642045, 2426520470557921222, 50969651457241797955, 1121574207307049758778
OFFSET
0,3
FORMULA
D-finite with recurrence a(n) -n*a(n-1) +a(n-2) -n*a(n-3)=0. - R. J. Mathar, Jun 04 2021
MAPLE
a:= proc(n) a(n):= `if`(n<2, n, n! - a(n-2)) end:
seq(a(n), n=0..23); # Alois P. Heinz, Jun 04 2021
MATHEMATICA
nxt[{n_, a_, b_}]:={n+1, b, (n+1)!-a}; NestList[nxt, {1, 0, 1}, 30][[;; , 2]] (* Harvey P. Dale, Feb 15 2024 *)
PROG
(Python)
prpr = 0
prev = f = 1
for n in range(2, 33):
print(prpr, end=', ')
f *= n
curr = f - prpr
prpr = prev
prev = curr
CROSSREFS
Cf. A000142.
Cf. A005165: a(0) = 0, a(n) = n! - a(n-1).
Sequence in context: A177251 A041807 A228711 * A115602 A115601 A015557
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Aug 03 2012
STATUS
approved