Naive implementation of partial summation problem