complete Project Euler problem 22