Lecture 04 Ticket

Complete before the beginning of class on Friday, 09/09/2022

Download this ticket in pdf format or .tex source.

Consider the following method that on input a positive integer n sums the odd numbers from 1 to 2n1:

1
2
3
4
5
6
  Sum(n):
    total <- 0
    for k = 1 up to n do
      total <- total + 2 * k - 1
    endfor
    return total

Observe that for n=1,2,3,4, Sum(n) returns the values 1,4,9,16. In each case, the value returned by Sum(n) is n2. Use induction to argue that this formula always holds: for every positive integer n, the value returned by Sum(n) is n2.

Solution

We will argue the following claim