Finding the sum of a sequence