paddockpass/ruby_algo/ex5.rb
2017-08-01 23:31:06 +02:00

21 lines
390 B
Ruby

# 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