Solution for the 6th Euler problem.