Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2019
What would you like to do?
Fast O(log n) computation of n-th fibonacci number.
import numpy as np
n = int(input())
M = np.matrix([[1,1],[1,0]], dtype="object")
ans = (M**n)[0,0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment