import decimal def formulaFibWithDecimal(n): decimal.getcontext().prec = 3000000 root_5 = decimal.Decimal(5).sqrt() phi = ((1 + root_5) / 2) a = ((phi ** n) - ((-phi) ** -n)) / root_5 return round(a) print(formulaFibWithDecimal(1000000000))