title: systematically solve algebra (brute force method)
body: <p>I've searched around and tried myself, but couldn't quite figure out how to do it.</p>
  
  <p>I have an equation, say <code>a^2 + b^2 = c^2</code>. I want to find what integers a, b, and c have to be to make this equation true using JavaScript (node.js). Obviously we know that it could be many things (such as <code>a = 3, b = 4, and c = 5</code>, but I'm only looking for the first answer the computer musters, no matter the answer. The only specification is that it must be an integer greater than 0, and solve it with brute force method, or just plugging in tons of numbers until it is true. </p>
  
  <p>an example/one way I've thought of doing it is:</p>
  
  <pre><code>var
    a = 1;
    b = 1;
    c = 1;
  
  if (Math.pow(a,2) + Math.pow(b,2) === Math.pow(c,2)) {
      console.log('you did it!');
  } else {
      //something such as a++ or idk
    }
  </code></pre>
  
  <p>I don't know what to do for if the equation isn't true. My idea was first adding 1 to a, then subtracting 1 from a and adding 1 to b, and so on until the equation is true... sorta like <a href="https://stackoverflow.com/questions/5226895/combine-array-of-array-into-all-possible-combinations-forward-only-in-ruby">this here</a></p>
  
  <p>If you have any ideas on how to best do this, or if someone has solved this before and I couldn't find the source, please share!</p>
  
  <p>Thanks</p>