Proof by Induction
Basis Step: The algorithm is correct for the base case (e.g. n=0) by inspection.
Inductive Hypothesis (n=k): Assume that the algorithm works correctly for the first k cases, for any k.
Inductive Step (n=k+1): Given the hypothesis above, show that the k+1 case will be calculated correctly.