title: Algorithm fails to find triangular number with more than 500 divisors
body: <p>I've been working through a problem from the Project Euler website (<a href="https://projecteuler.net/problem=12" rel="nofollow">problem 12</a>) but I can't figure out why my code isn't working.  The obective of the code is that it should find the smallest triangular number that has over 500 divisors.</p>
  
  <pre><code>private static long triangleNumber() {
  
      long currentTriangleNumber = 0;
      long triangleNumber = 0;
      int counter = 0;
  
      while (triangleNumber == 0) {
          counter++;
          currentTriangleNumber += counter;
          int divisorCounter = 0;
          for (int i = 1; i &lt;= counter; i++) {
              if ((currentTriangleNumber % i) == 0) {
                  divisorCounter++;
                  if (divisorCounter &gt;= 500) {
                      triangleNumber = currentTriangleNumber;
                  }
              }
          }
      }
  
      return triangleNumber;
  }
  </code></pre>
  
  <p>The code returns 842161320, which is not the right answer. As far as I can see, the problem does not lie within the syntax and the code does not output any sort of error message. The answer, from what I've briefly looked up should be 76576500.</p>
  
  <p>Can explain why the code is not finding the solution?</p>