title: Quadratic Equations factor computation
body: <p>Regarding quadratic equations (learn more <a href="http://www.mathsisfun.com/algebra/quadratic-equation.html" rel="nofollow noreferrer">here</a>), I've taken the <code>a</code>, <code>b</code>, and <code>c</code> of the equation as input. </p>
  
  <p>A sample equation will be this: 21x^2 - 8x - 4 
      Here, a = 21, b = -8, c = -4. So, on solving (without formula), 
      => 21x^2 - 14x + 6x - 4 = 0.</p>
  
  <p>I need the two middle numbers, that is, in this case 14 and 6 (read factors). I think I have done all correct, but the input seems to be infinite and does not stop at all. Can you please rectify the mistake? I am also curious to learn why that happened. </p>
  
  <pre><code>import java.util.Scanner;
  public class QuadFact {
      static Scanner sc = new Scanner(System.in); 
      static int a,b,c; 
      static int P, diff, p; 
      static int i;
      static boolean found = false;
  
      void accept(){
          System.out.println("Enter the a, b, c");
          a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();
      }
  
      void compute(){
          P = a * c;
          diff = 0;
          while(!found){
             for (i = b + 1;;i++){
                  diff = i - b;
                  p = i * diff;
                  if (p==P) {
                      found = true;
                      break; 
                  }
              }
          }
      }
  
      void display(){
          System.out.print("These are the raw numbers, should be   correct.  
          Still,\n it is advisable you verify it.");
          System.out.println("One factor: " + i);
          System.out.println("Other factor: " + diff);
      }
  
      public static void main(String[] args){
          QuadFact a = new QuadFact();
          a.accept();
          a.compute();
          a.display();
      }
  }
  </code></pre>