title: Prime factors using recursion in Java
body: <p>I'm having trouble with recursion in java. So I have the following method and i should transform it only with recursion without any loop.</p>
  
  <pre><code>public static List&lt;Integer&gt; primesLoop(int n) {
      List&lt;Integer&gt; factors = new ArrayList&lt;Integer&gt;();
      int f = 2;
      while (f &lt;= n)
          if (n % f == 0) {
              factors.add(f);
              n /= f;
          } else
              f++;
      return factors;
  }
  </code></pre>
  
  <p>The recursive method should start with the same form:</p>
  
  <pre><code>public static List&lt;Integer&gt; primesRec(int n);
  </code></pre>
  
  <p>and also I should define help methods for the transformation
  The result is for example:</p>
  
  <pre><code>primesRec(900) -&gt; prime factors of 900 : [2, 2, 3, 3, 5, 5]
  </code></pre>