/19. Quadratic Equation Secret
Last active
May 20, 2018 13:35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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