title: Write function which is return array of prime factors
body: <p>I have a function it returns prime factors of a number but when I initialize int array I set size.So the result consists unnecessary <strong>zeros</strong>.How can I return result array without zeros or how can I initialize array applicable size? I am not using <strong>Lists</strong></p>
  
  <pre><code>public static int[] encodeNumber(int n){
          int i;
          int j = 0;
          int[] prime_factors = new int[j];
          if(n &lt;= 1) return null;
          for(i = 2; i &lt;= n; i++){
              if(n % i == 0){
                  n /= i;
                  prime_factors[j] = i;
                  i--;
                  j++;
              }
          }
          return prime_factors;
      }
  </code></pre>
  
  <p>Thanx!!! </p>