Prove Recursive formula (Dynamic programming) N(C,i) I've been asked to prove the correctness of the following recursive formula. The formula is trying to define, how many ways you can spend your money C on the i amount of beers. I did the following recursive formula where you either bought a beer and losing $P-i$ money, or passed the beer and went for the next in the array $i-1$. You cannot buy the same type of beer twice.

$$N(C,i)=\begin{cases}
    0       &amp; \quad \text{if } C&lt;0\;||\; i&lt;0 \\
    1       &amp; \quad \text{if }  C=0\\
    N(C,i-1)+N(C-P_i,i-1)  &amp; \quad otherwise
  \end{cases}
$$

I'm not certain how to prove the correctness of the algorithm. Especially because the assignment is about dynamic programming, and I can't find any repeated subproblems. The amount of money you will have will differ unless some of the different beers cost the same. I asked a fellow student who said the problem will always give overlapping subproblems. 
 
The problem has also been talked about here (Making a recursive formula for finding amount of ways to spend money on beer), but I think my recursive formula is correct.

Sorry, if the question is unclear, or if I've done something wrong. It's the first time on stackexchange, and I think, this is the place to ask the question and not the mathmatics site.
I figured it out.

Overlapping-subproblems:


$P_i == P_{i_1}$: If two beers has the same price it will give overlapping subproblems. The assignment thinks this is okay.
$P_i == P_{i-1}+P_{i-2}$: If a collection of beer has the same price as another collection of beers they will end up with the same parameter $C$. Because every left call doesn't change the value of $C$ it will give overlapping subproblems.


Proof of Correctness

I thought I had to prove the algorithm through induction with a mathematical equation. This wasn't the case. I had to prove that simple base-cases would give the correct value, and that the recursive calls would get closer to the 1st and 2nd statement and prove that the algorithm would eventually terminate.


Case 1: If $C = 0$, then $N(C,i)=1$
Case 2: If $i = 0$ and $C!=0$, then $N(C,i)=0$ (Had to edit my formula. The assignment specified that you had to use all your money) 
and more...