Skip to content

Instantly share code, notes, and snippets.

@abouolia
Last active December 17, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abouolia/1cee66b9cf1b6ed0480a to your computer and use it in GitHub Desktop.
Save abouolia/1cee66b9cf1b6ed0480a to your computer and use it in GitHub Desktop.
Second Degreee Quation
<?php
function Seconddegreeequation( $a, $b, $c, $g=null){
if ( $g == 1 || $g == true){
$val = (-1 * $b) + sqrt(pow($b, 2) - 4*$a*$c);
}else{
$val = (-1 * $b) - sqrt(pow($b, 2) - 4*$a*$c);
}
$val2 = 2*$a;
return $val / $val2;
}
echo Seconddegreeequation(1, -3, -18, true);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment