total = 0 while(true) do line = gets if line == nil then break end numbers = line.split(' ').map do |num| num.to_i end for i in (0..numbers.length - 1) do for j in ((i + 1)..numbers.length - 1) do pair = [numbers[i], numbers[j]] max = pair.max min = pair.min if max % min == 0 then total += max / min next end end end end puts(total)