Solution for Spartez "Iteration" task.