from math import sqrt def fibo(n): atual, prox = 0, 1 for i in range(n): atual, prox = prox, atual+prox return atual fi = (1+sqrt(5))/2 psi = (1-sqrt(5))/2 inv_raiz_5 = 1/sqrt(5) def binet(n): return int(inv_raiz_5 * (fi**n - psi**n))