我正在添加所有小于 1000 的 3 和 5 的倍数的数字。
这是我的错误:
in `multiple_sum': undefined method `<' for nil:NilClass (NoMethodError)
这是我的代码:
def multiple_sum(n)
  five_total, three_total, three_subtract = 0
  while five_total < n
    five_total += five_total+5
  end
  while three_total < n
    if (three_total+3)%5 == 0
      three_subtract += three_total+3
    end
    three_total += three_total+3
  end
  puts (three_total-three_subtract) + five_total
end
multiple_sum(1000)
while我的循环条件有问题吗?