The most straightforward method would be to apply the formula directly. Loop on j computing Fj along the way if n<=1 : return n Fold=0 Fnew=1 for j in range(2,n) : Fold, Fnew = Fnew, Fold+Fnew return Fnew Even simpler: return round(((1+sqrt(5.))/2)**n/sqrt(5.))