Created
October 12, 2016 22:34
-
-
Save ugofred/dc522e5061f2d164b07f65fad7d22137 to your computer and use it in GitHub Desktop.
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
def quad_eq(eq) | |
alpha = eq[0].to_f | |
beta = eq[1].to_f | |
gamma = equation[2].to_f | |
omega = beta**2 - (4 * alpha * gamma) | |
if omega < 0 | |
print "The equation has no roots" | |
return | |
end | |
x1 = (-b + Math.sqrt(d)) / (2 * a) | |
x2 = (-b - Math.sqrt(d)) / (2 * a) | |
return [x1, x2] | |
end | |
eq = [5,6,1] | |
roots = quad_eq(eq) | |
print(roots) | |
puts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment