Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Viveka Fischer   on May 30 In Java Category.

  
Question Answered By: Hadil Khan   on May 30

the GCD method  has to be a recursive method ( use GCD within a GCD method).

public int  GCD(int a, int b) {
int intP = a, intQ = b;
while (intP % intQ !=0) {
int intR = intP % intQ;
intP = intQ; intQ = intR;
}
Return GCD ( intP, intQ);
}

and I do not think the method has to be static  method.

Share: