summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/my_pow/my_pow.c
blob: f529d87ce632c7e7cc8cd0c42392ee14dbb2574a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
int my_pow(int a, int b)
{
    if (!a)
        return b == 0;
    int res = 1;
    for (int i = 0; i < b / 2; i++)
    {
        res *= a * a;
    }
    if (b % 2)
        res *= a;
    return res;
}