Added another version of exercise 4 with an accumulator