title: Factorization of an integer
body: <p>While answering another, I stumbled over the question how I actually could find all factors of an integer number <strong>without</strong> the <em>Symbolic Math Toolbox</em>.</p>
  
  <p>For example:</p>
  
  <pre><code>factor(60)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code> 2     2     3     5
  </code></pre>
  
  <hr>
  
  <pre><code>unique(factor(60))
  </code></pre>
  
  <p>would therefore return all prime-factors, <strong>"1"</strong> missing. </p>
  
  <pre><code> 2     3     5
  </code></pre>
  
  <hr>
  
  <p>And I'm looking for a function which would return all factors (<strong>1</strong> and <strong>the number itself</strong> are not important, but they would be nice)</p>
  
  <p><strong>Intended output for <code>x = 60</code>:</strong></p>
  
  <pre><code> 1     2     3     4     5     6    10    12    15    20    30    60     
  </code></pre>
  
  <hr>
  
  <p>I came up with that rather bulky solution, apart from that it probably could be vectorized, isn't there any elegant solution?</p>
  
  <pre><code>x = 60;
  
  P = perms(factor(x));
  [n,m] = size(P);
  Q = zeros(n,m);
  for ii = 1:n
      for jj = 1:m
          Q(ii,jj) = prod(P(ii,1:jj));
      end
  end
  
  factors = unique(Q(:))'
  </code></pre>
  
  <p>Also I think, this solution will fail for certain big numbers, because perms requires a vector length &lt; 11.</p>