title: Ruby. How to improve my loop that searches for the smallest multiple of ranges of numbers
body: <p>I need to deal with this task:</p>
  
  <p>"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?"</p>
  
  <p>My solution looks like this:</p>
  
  <pre><code>all_numbers = []
  
  1.upto(2600) do |j|
       1.upto(10) do |i|
              if j % i == 0 
                  all_numbers &lt;&lt; j
                  end
       end
  end
  
  result = all_numbers.select{|element| all_numbers.count(element) &gt; 9 }
  p result[0]
  </code></pre>
  
  <p>This gives me the right answer,  but if I want to check for a range of <code>0..20</code>and change code like this:</p>
  
  <pre><code>all_numbers = []
  
  1.upto(100000) do |j|
       1.upto(20) do |i|
              if j % i == 0 
                  all_numbers &lt;&lt; j
                  end
       end
  end
  
  result = all_numbers.select{|element| all_numbers.count(element) &gt; 19 }
  p result[0]
  </code></pre>
  
  <p>it takes too much time to receive an answer (actually, I didn't even waited so long... So don't have the right answer yet..).</p>
  
  <p>Any ideas? Many thanks!</p>