21 lines
390 B
Ruby
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
|