Created
February 18, 2013 20:10
-
-
Save moitorrijos/4980258 to your computer and use it in GitHub Desktop.
A quadratic equation solver in JS
This file contains hidden or 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
var quadEquationSolver = function (a, b, c) { | |
var rootPart = Math.sqrt( (b * b) - (4 * a * c) ); | |
var denom = 2 * a; | |
var firstRoot = (-b + rootPart)/denom; | |
var secondRoot = (-b - rootPart)/denom; | |
console.log("The first root is " + firstRoot); | |
console.log("The second root is " + secondRoot); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment