Problem 70 (Ruby is too slow to solve this task)