exercise 2.57 arbitrary number of terms for sum and product