Advertisement
-Annie-

QuadraticEquation

May 26th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calc(a, b, c) {
  2.     let D = Math.pow(b, 2) - 4 * a * c;
  3.  
  4.     if (D > 0) {
  5.         let x1 = (-b - Math.sqrt(D)) / (2 * a);
  6.         let x2 = (-b + Math.sqrt(D)) / (2 * a);
  7.         console.log(x1);
  8.         console.log(x2);
  9.     }
  10.  
  11.     else if (D == 0){
  12.         let x = -b / (2 * a);
  13.         console.log(x);
  14.     }
  15.  
  16.     else if (D < 0) {
  17.         console.log('No');
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement