In the code if b == 0
it will not return an int
or any value for that matter. You must handle this condition, most likely by specifying a default return value.
public static int GCD(int a, int b)
{
while (b != 0)
{
int r = a%b;
System.out.println("(" +a+ "," +b+ ")");
b = r;
a = b;
if(b == 0)
{
return a;
}
}
return 0;
}