Sum Quadratic Roots

Published by Morgan Moore in

Given a, b and c, find the roots of the equation ax^2 +bx +c and then add them together.

  • Round your answer to two decimal places.
  • If there is only one real root return 1.
  • If there are no real roots, return 0.

Examples

findRootsSum(2, 4, -6) ➞ -2.00f

findRootsSum(3, 4, -3) ➞ -1.33f

findRootsSum(4, 3, -8) ➞ -0.75f

Notes

The Discriminant of a quadratic equation is b^2-4(a)(c).

Watch a quick demo on how Edabit works.