Skip to main content

Diophantine

In mathematics, a Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integer solutions are sought or studied (an integer solution is such that all the unknowns take integer values). A linear Diophantine equation equates the sum of two or more monomials, each of degree 1 in one of the variables, to a constant. An exponential Diophantine equation is one in which exponents on terms can be unknowns.


function diophantine(a,b,c)
{
  //Logic
  if (a === 0 && b === 0)
  {
    if (c == 0)
    {
      return "Infite Solutins";
    }
    else
    {
      return "Finite Solutions"
    }
  }
  
  // Refer to Euclidean Post for details of the function
  var res = euclidean(a, b);
  var gcd = res[0];
  var x = res[1];
  var y = res[2];

  if (c % gcd != 0)
  {
    return "No Solution";
  }
  else
  {
    var ans = [x * (c / gcd) , y * (c / gcd)];
    return ans;
  }
}