from decimal import Decimal, getcontext def bank(years:int) -> float: """ Warning: still will diverge and return incorrect results after 250 years the higher the precision, the more years will cover """ getcontext().prec = 500 # standard math.e has not enough precision e = Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668082264800168477411853742345442437107539077744992069551702761838606261331384583000752044933826560297606737113200709328709127443747047230696977209310141692836819025515108657463772111252389784425056953696770785449969967946864454905987931636889230098793127736178215424999229576351') decimal_balance = e - 1 for year in range(1, years+1): decimal_balance = decimal_balance * year - 1 return(float(decimal_balance)) print("Bank balance after 25 years = ", bank(25))