title: Why is it implying I'm dividing by zero?
body: <p>I'm solving a few exercises from HackerRank.com and the code works perfectly on Netbeans and even in the page compiler for test cases, but when I submit the code it throws me this error in every test(except the last):</p>
  
  <blockquote>
    <p>ArithmeticException: thrown at Solution.main(Solution.java:15)</p>
  </blockquote>
  
  <p>Here's the code:</p>
  
  <pre><code>     Scanner s = new Scanner(System.in);
       int a = s.nextInt(),j=1;
       for(int i=0; i&lt;a; i++){
           int b = s.nextInt(), c =s.nextInt();
           for(j = b*c; j&gt;0;j--) {
           if((b*c)%(j*j)==0){
               System.out.println(b*c/(j*j));
               break;}
           } 
       }
  </code></pre>
  
  <p>Line 15 is:</p>
  
  <pre><code>    if((b*c)%(j*j)==0){
  </code></pre>
  
  <p>What's wrong with the statement? 
  I've set 'j' to be different from 0 in the for loop, so no reason for dividing by zero, which was the only explanation I could find by myself.</p>
  
  <p>Thank you in advance.</p>