A decent gcd code
This is a very decent code to calculate gcd. I found this when I was doing the water and jug problem. public static int gcd(int x, int y) { while (y != 0) { int tmp = y; y = x % y; x = tmp; } return x; }
This is a very decent code to calculate gcd. I found this when I was doing the water and jug problem. public static int gcd(int x, int y) { while (y != 0) { int tmp = y; y = x % y; x = tmp; } return x; }