Negasus

Untitled

Oct 16th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. <?php
  2.  
  3. function a($a, $b, $c) {
  4.  
  5.     $d = $b * $b - 4 * $a * $c;
  6.     if ($d < 0) return false;
  7.  
  8.     $x1 = (-$b + sqrt($d)) / (2 * $a); 
  9.     $x2 = (-$b - sqrt($d)) / (2 * $a);
  10.  
  11.     $res = [
  12.         'x1' => $x1,
  13.         'x2' => $x2
  14.     ];
  15.  
  16.     return $res;
  17. }
  18.  
  19.  
  20. echo '<pre>';
  21. var_dump(a(1, 1, -6));
  22. echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment