Skip to content

Instantly share code, notes, and snippets.

@Nikola-Andreev
Last active May 20, 2018 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikola-Andreev/0ff685f863c68a0c9d20b6bc71c8c20f to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/0ff685f863c68a0c9d20b6bc71c8c20f to your computer and use it in GitHub Desktop.
function solve(a, b, c) {
let discriminant=b*b-4*a*c;
let x1=0;
let x2=0;
if(discriminant>0) {
x1=(-b+Math.sqrt(discriminant))/(2*a);
x2=(-b-Math.sqrt(discriminant))/(2*a);
console.log(Math.min(x1,x2));
console.log(Math.max(x1,x2));
} else if(discriminant === 0) {
x1=-(b/(2*a));
console.log(x1);
} else {
console.log("No");
}
}
solve(6, 11, -35);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment