您的位置:首页 > 其它

ProjectRuler-5

2011-11-04 12:41 141 查看
#2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
#What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
#answer : 232792560
#
#待修改,效率不高

def devided
a = []
flag = true
(1..3_0000_0000).to_a.each do |number|
2.upto(10) do |i|
rod = number.to_f/i
if rod != rod.to_i
break
else
a.push(number)
flag = false
end
end
break if !flag
end
puts a[-1]
end

devided
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: