Solver Reducing Fractions Calculator
Algebra
->
Algebra
->
Numeric Fractions Calculators, Lesson and Practice
-> Solver Reducing Fractions Calculator
Log On
Ad:
Algebrator™
solves your algebra problems and provides step-by-step explanations!
Ad:
Algebra Solved!™
: algebra software solves algebra homework problems with step-by-step help!
Algebra: Numeric Fractions
Solvers
Lessons
Problems, free tutors
Quiz
In Depth
Source code of 'Reducing Fractions Calculator'
This Solver (Reducing Fractions Calculator)
was created by by
jim_thompson5910(13794)
:
View Source
,
Show
,
Put on YOUR site
About jim_thompson5910
:
==section input Enter the numerator *[input num=2]. Enter the denominator *[input denom=4] Note: enter WHOLE numbers only ==section solution perl if($num=~m/\./ or $denom=~m/\./) { die "Only enter WHOLE numbers please"; } sub gcf { my ($x, $y) = @_; ($x, $y) = ($y, $x % $y) while $y; return $x; } sub lcm { return($_[0] * $_[1] / gcf($_[0], $_[1])); } sub multigcf { my $x = shift; $x = gcf($x, shift) while @_; return $x; } sub multilcm { my $x = shift; $x = lcm($x, shift) while @_; return $x; } if(($denom<0)&&($num>0)) {$denom=abs($denom); $num=0-$num;} if(($denom<0)&&($num<0)) {$denom=abs($denom); $num=abs($num); $both_neg=1;} sub reduce{ my @arr1=@_; my @original_arr1=@arr1; if($arr1[0]==0) {return $arr1[0];} if($arr1[1]!=0) { my $gcf=gcf($arr1[0],$arr1[1]); $exported_gcf=$gcf; $arr1[0]/=$gcf; $arr1[1]/=$gcf; } return ($arr1[0],"/",$arr1[1]); } if($denom==0 && $num==0) { print "Cannot find number. Indeterminate form"; return undef; } if($denom==0) { print "Undefined: Cannot divide by 0. Think about it, if you have {{{$num/0=y}}} you can rewrite this as {{{$num=0*y}}} or {{{$num=0}}} which is obviously not true. In a more plain sense, think of a number that you can multiply by zero that gives you $num. There is no such number, so the solution is undefined."; return undef; } my $start_num=$num, $start_denom=$denom, $i, $j=0, $quotient=$num/$denom; if($num%$denom==0) { print " Since $num is divisible by $denom, to reduce {{{$num/$denom}}} simply divide $num by $denom {{{$num/$denom=$quotient}}}"; return; } @temp1=reduce($start_num,$start_denom); $num=$temp1[0]; $denom=$temp1[2]; #for ($i=$num*$denom; $i>1; $i--) #{ # if (($num%$i==0)&&($denom%$i==0)) # { # $num/=$i; # $denom/=$i; # $j=$i; # # } #} if($exported_no_reduce==1) { print "This fraction is not reducible. The reason is simply because $num and $denom do not have a common factor (other than 1) between them. So the fraction stays as {{{$num/$denom}}}"; return; } if($exported_gcf==1) { print "This fraction is not reducible. The reason is simply because $num and $denom do not have a common factor (other than 1) between them. So the fraction stays as {{{$num/$denom}}}"; return; } if($exported_no_reduce!=1) { print "In order to reduce {{{$start_num/$start_denom}}}",($both_neg==1)?"(note: {{{(-$start_num)/(-$start_denom)=$start_num/$start_denom}}})":""; print ", the numerator and denominator must share a common factor. This common number must evenly divide into both of them without any remainder or decimal. In order to completely reduce the fraction, you must divide the numerator and the denominator by the greatest common factor (GCF). The GCF of {{{$start_num}}} and {{{$start_denom}}} is {{{$exported_gcf}}} (note: click <a href=http://www.algebra.com/algebra/homework/divisibility/find-greatest-common-factor.solver>here</a> if you need help with finding the GCF). So divide both the numerator and denominator by {{{$exported_gcf}}} In other words, to reduce the fraction you do this {{{(numerator/GCF)/(denominator/GCF)=Reduced_Fraction}}} {{{($start_num/$exported_gcf)/($start_denom/$exported_gcf)}}} Plug in the numerator, denominator, and the GCF"; print " {{{($num)/($start_denom/$exported_gcf)}}} Now divide $start_num by $exported_gcf to get $num. This is now the new numerator. {{{$num/$denom}}} Now divide $start_denom by $exported_gcf to get $denom. This is now the new denominator. So {{{($start_num/$exported_gcf)/($start_denom/$exported_gcf)=$num/$denom}}} "; print " This means that {{{$start_num/$start_denom}}} reduces to {{{$num/$denom}}} In other words, {{{$start_num/$start_denom=$num/$denom}}} "; } ==section output angle1 ==section check num, denom ==section check num, denom