second problem from ProjectEuler.net