Skip to content

Instantly share code, notes, and snippets.

@ugofred
Created October 12, 2016 22:34
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 ugofred/dc522e5061f2d164b07f65fad7d22137 to your computer and use it in GitHub Desktop.
Save ugofred/dc522e5061f2d164b07f65fad7d22137 to your computer and use it in GitHub Desktop.
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