I say you need help, this is Java.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
div = num1 / num2;
remainder = num1 % num2;
1)Let num1 = 6 and num2 = 3. Then div = 6/3 = 2. and the remainder 6%3 = 0.
2)
if (num1 < num2)
{
div = num1;
num1 = num2;
num2 = div;
}
This is irrelevant in the above case since num1 > num2. So its skipped.
3)
while(remainder != 0)
{
div = num1 / num2;
remainder = num1 % num2;
num1 = num2;
num2 = remainder;
}
num2 = GCD;
Since remainder is 0, this won't get executed and num2 is set to GCD which you haven't defined, so it will be 0. You see your problem?
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608