From the mind of Kon Pik…

Hopeless without the internet

Fraction Reducer v1.0

My fraction reducer. It’s a quick hackjob, and will do more than more (or just as much) as the fraction reducers out there. If you crash it, you’ll know – the page won’t load. You’ll have to just refresh your browser or go back to the main page.

Good luck.
[exec]
$mynum = (double)$_POST[‘num’];
$mydem = (double)$_POST[‘dem’];
if ($mydem != 0)
{
$answer = gcd($mynum, $mydem);
echo “

“.$mynum.”/”.$mydem.” has a GCD of “.$answer.”
“;
echo “Once reduced, the fraction becomes “.$mynum / $answer.”/”.$mydem/$answer.”“;
}

function gcd($a, $b){
$b = ( $a == 0 )? 0 : $b;
return ( $a % $b )? gcd($b, abs($a – $b)) : $b;
}
[/exec]

Numerator
Denominator