This is one of the best algorithms to calculate the nth Fibonacci sequence. it needs O(log(n)) time to do its job, so it's so efficient. I found it somewhere but don't know how it works!Can anyone tell me how this algorithm works? thanks.Here's the code:int fib3 (int n) {    int i = 1, j = 0, k = 0, h = 1, t;    while (n > 0) {        if (n % 2) {            t = j * h;            j = i * h + j * k + t;            i = i * k + t;        }        t = h * h;        h = 2 * k * h + t;        k = k * k + t;        n /= 2;    }    return j;}
How this Fibonacci exponentiation by squaring algorithm works?
algorithms