You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
I'm not fluent in Java so I won't implement it by myself, however there is an O(log n) solution for finding nth Fibonacci number which is based on matrix exponentiation -
[[1 1] [1 0]]^n = [[F_{n+1} F_n] [F_n F_{n-1}]]
This can be done with exponentiation by squaring which is O(log n).
The text was updated successfully, but these errors were encountered:
@cktang88 uhmm, it's not? There's exponentiation here which uses at least O(log n) multiplications. Moreover, these are floating point numbers, which are probably slower to operate on than four integers.
Hello.
I'm not fluent in Java so I won't implement it by myself, however there is an
O(log n)
solution for finding nth Fibonacci number which is based on matrix exponentiation -This can be done with exponentiation by squaring which is
O(log n)
.The text was updated successfully, but these errors were encountered: