1. Learn
  2. /
  3. Courses
  4. /
  5. Probability Puzzles in R

Exercise

Write a function to check factorability

Let us write a function to evaluate whether any given quadratic is factorable or not. The arguments to the function will be the coefficient values a b and c for a given quadratic of the form $$ ax^2 + bx + c $$

and we will determine whether the discriminant of the quadratic formula $$ b^2 - 4ac $$

is a perfect square. If it is, then the quadratic is factorable.

Instructions

100 XP
  • Fill in the condition to check whether the solutions to the quadratic equation are imaginary.
  • Write the conditional statement to specify that the next section should run only when the previous condition is FALSE.
  • Return the result of the check for whether the discriminant is a perfect square, thus making the quadratic factorable.