plduhoux
2/20/2018 - 5:41 PM

divideAsLongAsPossible

int divideAsLongAsPossible(int n, int d) {
    while (n >= d && n % d == 0) {
        n /= d;
    }
    return n;
}