문제: app.codility.com/programmers/lessons/12-euclidean_algorithm/chocolates_by_numbers/
ChocolatesByNumbers coding task - Learn to Code - Codility
There are N chocolates in a circle. Count the number of chocolates you will eat.
app.codility.com
if (N == 1) return 1;
int gcd = getGCD(N, M);
return N / gcd;
static int getGCD(int N, int M)
{
if (M == 0) return N;
return getGCD(M, N % M);
}
'공부하자 > Codility' 카테고리의 다른 글
[Codility] Lesson12. CommonPrimeDivisors (C#) (0) | 2020.11.27 |
---|---|
[Codility] Lesson11. CountSemiprimes (C#) (0) | 2020.11.27 |
[Codility] Lesson11. CountNonDivisible (C#) (0) | 2020.11.27 |
[Codility] Lesson10. Peaks (C#) (0) | 2020.11.27 |
[Codility] Lesson10. MinPerimeterRectangle (C#) (0) | 2020.11.27 |