A collection of codes containing the solution you are looking for.
A collection of codes containing the solution you are looking for.
function fibn(n) { //Logic fib = Array(2).fill(1).map(x => Array(2).fill(1)); fib[1][1] = 0; if(n === 0) { return 0; } else { //Refer to Matrix Power Post for details of the function var ans = mat_power(fib, n - 1); return ans[0][0]; } }