[ create a new paste ] login | about

Link: http://codepad.org/JBxMgHBd    [ raw code | output | fork ]

PHP, pasted on Mar 7:
<?php

finder(5,6);

finder(-1,-33);

function finder($add,$product)
{

 $inside_root = $add*$add - 4*$product;

 if($inside_root >=0)
 {

     $b = ($add + sqrt($inside_root))/2;
     $a = $add - $b;

     echo "$a+$b = $add and $a*$b=$product\n";

 }else
 {
   echo "No real solution\n";
 }
}

?>


Output:
1
2
2+3 = 5 and 2*3=6
-6.2662812973354+5.2662812973354 = -1 and -6.2662812973354*5.2662812973354=-33


Create a new paste based on this one


Comments: