def fast_pow(x, n):
    accum = 1
    p2 = x
    while n:
        if n % 2:
            accum *= p2
        p2 = p2 * p2
        n //= 2

    return accum

It's fast exponentiation in Python. If you want, check it in Rust. It works because squaring gives us powers of two in x's exponent. On the first iteration p2=x1p2 = x^1, on the second p2=x2p2 = x^2, then p2=x4p2 = x^4, then p2=x8p2 = x^8 etc. Then we use accum *= p2 in order to collect together powers back to initial value of nn. In the code on GitHub there are some boring details you should keep in mind in an interview. Negative exponents, x equal to zero, blah blah blah. I hate this stuff.

Stop. I promised you fast Fibonacci. But we talked about quick power, which is totally unrelated. Or is it?