summaryrefslogtreecommitdiff
path: root/graphs/piscine/greatest_divisor/greatest_divisor.c
blob: 4c8efefab6041c38ffc64b5701d29dd2f053d57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
unsigned int greatest_divisor(unsigned int n)
{
    if (n == 0 || n == 1)
    {
        return 1;
    }

    int i;
    for (i = n / 2; i > 0 && n % i; i--)
    {
        continue;
    }

    return i;
}