title: Quickest way to find factors of a given number
body: <p>If I have a function <code>factors_of(number)</code>, and I'm looking for the fastest way to find all of the factors of that number.</p>
  
  <p>The fastest I have tried so far is</p>
  
  <pre><code>def factors_of(number)
    factors = 0
    n = 1
    while n &lt;= number
      if number % n == 0
        factors += 1
      end
      n += 1
    end
    factors
  end
  </code></pre>
  
  <p>but it gets sluggish as the numbers get larger. Do I need to iterate over n every time from <code>n..number</code> or is there a shortcut?</p>