공부하자/Codility
[Codility] Lesson12. ChocolatesByNumbers (C#)
ceste
2020. 11. 27. 13:24
문제: 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);
}