1. Use mathematical induction to prove
whenever n is a positive integer.
2. Use loop invariant to prove that the program for computing the sum of 1,...,n is correct.
INPUT: Integer n
OUTPUT: The sum of 1,...,n
S(n)
1. i ← 0
2. while n>0
3. do i ← i + n
4. n ← n-1
5. return(i)