private static int GreatestCommonDivisor(int a, int b) { while (b != 0) { var tmp = b; b = a % b; a = tmp; } return a; } }