Now I wanted to solve for a recurring function with RSolve
. Here's how I tried:
RSolveValue[{a[n] == n*a[n - 1] - n!, a[0] == 2}, a[n], n]
(*2 Pochhammer[1, n] - n Pochhammer[1, n]*)
Simplify[%, Element[n, Integers]]
(* -(-2 + n) Pochhammer[1, n] *)
FunctionExpand[%]
(* -(-2 + n) n Gamma[n] *)
Actually the result should be $(2-n)n!$, but how can I simplify the result by assuming n
be positive, so the result could look nicer.
FullSimplify[n Gamma[n], Element[n, Integers] && n > 0]
does simplify ton!
. $\endgroup$FullSimplify[n Gamma[n] (2 - n), n ∈ Integers && n > 0]
doesn't produce factorials, thus necessitating the use ofComplexityFunction
. $\endgroup$