Solution to project 3 on Project Euler