diff --git a/ruby_algo/ex5.rb b/ruby_algo/ex5.rb new file mode 100644 index 0000000..846a6fe --- /dev/null +++ b/ruby_algo/ex5.rb @@ -0,0 +1,20 @@ +# 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? + +x = 1 +n = 10 +a = (1..n) + +class Integer + def factors() (1..self).select { |n| (self % n).zero? } end +end + +puts x.factors + +unless x.to_a.length == 10 + x +=1 + x.factors +end