I will give a hint how you could have guessed the result yourself, with the stress on guess.
Take the sequence for rec(i, 6)
, i = 0,...,10. This is the sequence that you had already investigated. The answer is:
1 6 21 56 126 252 462 792 1287 2002
Now, insert it into Google (I don't know if other search engines can do the trick; Google certainly can). The first result should point you to this famous online encyclopedia:
https://oeis.org/A000389
This the Online Encyclopedia of Integer Sequences! Now, read the description:
A000389 Binomial coefficients C(n,5).
You may be not familiar with the C(*,*)
notation, but you can easily understatand its "Binomial coefficient" description.
You certainly notice the relation between 6 in your function and 5 in the answer formula, but to be sure you can repeat your experiment for several other numbers other than 6.
The next step is to see how the A000389 sequence looks like:
0, 0, 0, 0, 0, 1, 6, 21, 56, 126, 252, 462, 792, 1287, 2002, ...
Well, C(i,j) is undefined (or zero, depending on the convention) if i < j. Aha! A000389 is this:
C(0,5) = 0, C(1,5) = 0, ... , C(4,5) = 0, C(5,5) = 1, C(6,5) = 6,...
This is your sequence if you started from the term of index 5, if we start counting from 0.
res(0,6) = C(5,5), res(1,6) = C(6,5),..., res(k, 6) = C(5+k, 5)
You can generalize it to
res(k, j) = C(k + j - 1, j -1)
and then start thinking how to prove it in a mathematically strict way. The usual method is by mathematical induction - I'll skip it.
This final result is already given by @Botond_Horwath, I just show to you the magic of Google search engine + the OEIS website. (If you know the latter, the former is redundant).