strmtrpr
asked on
fractions part2
I have this recursive function again.
long gcd (long x, long y)
{
return (x==0L) ? y : gcd( y % x,x);
}
this is supposed to keep fractions in the lowest terms.
it works fine for addition and subtraction
how can I use it for multiplication and division.
I have always multiplied fractions like this
a/b *c/d = a *c / b*d
how can I use the gcd to reduce
thanks in advance.
long gcd (long x, long y)
{
return (x==0L) ? y : gcd( y % x,x);
}
this is supposed to keep fractions in the lowest terms.
it works fine for addition and subtraction
how can I use it for multiplication and division.
I have always multiplied fractions like this
a/b *c/d = a *c / b*d
how can I use the gcd to reduce
thanks in advance.
gcd(a*c,b*d)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that did it , I had the right idea I just messed up my syntax a little.
Thank you for your help.
Thank you for your help.