Note: while this isn't a strictly Mathematica, I am using it to find my results.
I have a problem where I integrate
E^x x^n
and I'm given results like
E^x (720 - 720 x + 360 x^2 - 120 x^3 + 30 x^4 - 6 x^5 + x^6)
E^x (-120 + 120 x - 60 x^2 + 20 x^3 - 5 x^4 + x^5)
E^x (24 - 24 x + 12 x^2 - 4 x^3 + x^4)
where n = 6, 5, and 4, respectively.
For an assignment, I need to find a summation in which I can input an n and it gives me those results correctly. My issue is with the alternating alternative negatives though, since they are not constant with each degree. I've gotten this close:
e[x_, n_] := (E^x )*Sum[((n!/i!)*(x^i))*(-1)^(1 - i), {i, 0, n}]
and it gives me these answers
E^x (-720 + 720 x - 360 x^2 + 120 x^3 - 30 x^4 + 6 x^5 - x^6)
E^x (-120 + 120 x - 60 x^2 + 20 x^3 - 5 x^4 + x^5)
E^x (-24 + 24 x - 12 x^2 + 4 x^3 - x^4)
for n = 6, 5, and 4 once again, but now the even n's are not alternating right.
Perhaps its just something little that I'm missing, but I can't seem t figure out how to alternate alternating signs between odd and even n's.
Any help with this would be appreciated! Thanks in advance!
[Comment converted to answer] Is it as simple as throwing in a factor of $(-1)^n$? I guess that would change your factor to $(-1)^{1-i+n}$, right?