Solved task from projecteuler.net