answersLogoWhite

0

I assume numerator and denominator will be in two different variables, Just divide both of them by the greatest common factor.

Here is a method to calculate the greatest common factor; it is based on the fact that, for example, the greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 is calculated as 14 - 10 (or faster, to avoid repeated subtractions, 14 % 10).

public static void main(String[] args) {
System.out.println(gcf(300L, 200L));

}

static long gcf(long a, long b)
{
long c;
while (true)
{
c = a % b;
if (c == 0) break;
a = b;
b = c;

}
return b;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you write a rational number?

Not too tough . . . Any number that you can completely write down on paperis a rational number.


How do you write 0.2 as a rational number?

0.2 is a rational number in and of itself.


Is -8 a rational or irrational number?

rational. The fact that you could write it out in a fraction proves that it is.


Is 89.99 a rational number?

Any number that you can write down completely is a rational number. You did that with 89.99, so it's rational.


How do you write 6 as a rational number?

6 is a rational number. It can be written as 6/1


Is 8100 rational or irrational?

8,100 is the ratio of 8,100 to 1 . That's about as rational as you can get.The definition of a rational number is:A number that you can write as the ratio of two whole numbers.It also turns out that if you can write a number out completely with digits,then it's a rational number.


How can you write 721 as a rational number?

All integers are rational numbers so the answer is 721.


How do you write 1 as a rational number?

Answer: 1 already is a rational number. If you want to get technical, you could write it as 1/1. Answer: Any integer is a rational number. No matter how you write it, it will still be a rational number. Answer: 10/10, 2/2, 3/3, 365/365, etc.


Is 0.31 a rational number?

Write each rational number as b. 0.31


Why is 4.323223222 an irrational number if you can predict what comes next?

Being rational or irrational is not about "predicting the next digit"; the definition of a rational number is that you can write it as a fraction, with integer numerator and denominator.Being rational or irrational is not about "predicting the next digit"; the definition of a rational number is that you can write it as a fraction, with integer numerator and denominator.Being rational or irrational is not about "predicting the next digit"; the definition of a rational number is that you can write it as a fraction, with integer numerator and denominator.Being rational or irrational is not about "predicting the next digit"; the definition of a rational number is that you can write it as a fraction, with integer numerator and denominator.


Is 64 rational or irrational?

Rational


Is 12.52 rational or irrational?

12.52 is rational, as is any number that you can write out completely in decimal form.