from math import sqrt fi = (1 + sqrt(5))/2 psi = (1 - sqrt(5))/2 def F(n): return 7 * (fi**n) # print(fi**20 - (fi**19 + fi**18)) # print(psi**20 - (psi**19 + psi**18)) # print(F(20) - (F(19) + F(18))) def ex_2(n): a = (7 + 4j)/2j b = (-7 + 4j)/2j return a * ((0+1j)**n) + b * ((0-1j)**n)