solution for project euler 3.