title: Highest unique prime factors in range
body: <p>I am trying to scale a solution I have to a Hackerrank <em>practice</em> question.</p>
  
  <p>The question, in summary is, find the max number of prime factors in a range.</p>
  
  <p>For <code>1..500</code> it's <code>4 for 210 -&gt; 2(1), 3(1), 5(1), 7(1)</code><br>
  For <code>1..5000</code> it's <code>5 for 2310 -&gt; 2(1), 3(1), 5(1), 7(1), 11(1)</code><br>
  For <code>1..50000</code> it's <code>6 for 30030 -&gt; 2(1), 3(1), 5(1), 7(1), 11(1), 13(1)</code>  </p>
  
  <p>This is my solution</p>
  
  <pre><code>require 'prime'
  max = 0
  for d in 1..n
      pfs = d.prime_division.count
      max = pfs if pfs &gt; max
  end
  puts max
  </code></pre>
  
  <p>This takes forever for <code>n = 10000000000</code>.</p>
  
  <p>I may be looking at the solution from the wrong perspective.<br>
  How do I scale this solution?</p>