ChocolatesByNumbers【★★★】
1 /// <summary> 2 /// Solution - 好神奇的辗转相除法 3 /// 100/100 4 /// </summary> 5 /// <param name="N"></param> 6 /// <param name="M"></param> 7 /// <returns></returns> 8 public int solution(int N, int M) 9 { 10 return N / GCD(N, M); 11 } 12 13 public int GCD(int N, int M) 14 { 15 if (N % M == 0) 16 return M; 17 if (N < M) 18 return GCD(M, N); 19 return GCD(M, N % M); 20 }