title: Prime factorization algorithm fails for big numbers
body: <p>I have run into a weird issue for problem 3 of Project Euler. The program works for other numbers that are small, like 13195, but it throws this error when I try to crunch a big number like 600851475143:</p>
  
  <pre><code>Exception in thread "main" java.lang.ArithmeticException: / by zero
      at euler3.Euler3.main(Euler3.java:16)
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>    //Number whose prime factors will be determined
      long num = 600851475143L;
  
      //Declaration of variables
      ArrayList factorsList = new ArrayList();
      ArrayList primeFactorsList = new ArrayList();
  
      //Generates a list of factors
      for (int i = 2; i &lt; num; i++)
      {
          if (num % i == 0)
          {
              factorsList.add(i);
          }           
      }
  
      //If the integer(s) in the factorsList are divisable by any number between 1 
      //and the integer itself (non-inclusive), it gets replaced by a zero 
      for (int i = 0; i &lt; factorsList.size(); i++)
      {
          for (int j = 2; j &lt; (Integer) factorsList.get(i); j++)
          {
              if ((Integer) factorsList.get(i) % j == 0)
              {
                  factorsList.set(i, 0);
              }
          }
      }
  
      //Transfers all non-zero numbers into a new list called primeFactorsList
      for (int i = 0; i &lt; factorsList.size(); i++)
      {
          if ((Integer) factorsList.get(i) != 0)
          {
              primeFactorsList.add(factorsList.get(i));
          }
      }
  </code></pre>
  
  <p>Why is it only big numbers that cause this error?</p>