Naive solution for problem 004.