Solved problem 4 on project euler