I am a software developer, had maths 15 years ago (so I beg for forgiveness if my notation below hurts your eyes), and would like to calculate the number of elements a certain algorithm will produce. The algorithm is implemented, works fine, and I know how to calculate the number of elements using a complex formula: $$C(n) = n!/(n-1)! + n!/(n-2)! + n!/(n-3)! + ... + n!/0!)$$
where:
n = number of input elements (positive integer)
C(n) = count of all generated elements for input of size n
E.g.
$$ C(1) = 1!/0! = 1/1 = 1$$ $$ C(2) = 2!/1! + 2!/0! = 2 + 2 = 4$$ $$ C(3) = 3!/2! + 3!/1! + 3!/0! = 3 + 6 + 6 = 15$$ $$ C(4) = 4!/3! + 4!/2! + 4!/1! + 4!/0! = 4 + 12 + 24 + 24 = 64$$ $$ C(5) = 325$$ $$ C(6) = 1956$$ etc.
Is there a way to present the formula in a simpler, more concise way? I tried, but the simplest notation I count come up with is this:
$$C(n) = n + n*(n-1) + n*(n-1)*(n-2) + n*(n-1)*(n-2)*(n-3) + ... + n*(n-1)*(n-2)* ... * (n-(n-1))$$
Let's take 4 as an example:
$$ C(4) = 4!/3! + 4!/2! + 4!/1! + 4!/0!$$ $$ C(4) = 4*3!/3! + 4*3*2!/2! + 4*3*2*1!/1! + 4*3*2*1*0!/0!$$ $$ C(4) = 4 + 4*3 + 4*3*2 + 4*3*2*1$$
bit it is still complex and I can't generalize it for n. When I think of it, it seems kind of like an arithmetic progression, but there is no common difference. Any help?