#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
ProjectRuler-5
最新推荐文章于 2022-05-25 21:21:42 发布