python笔记


 

递归实现

问题假设,你有1万块钱,放进支付宝,1天收益为0.8元,一年后一共有多少钱?

def factorial(n):
  result = 10000 * 0.00008 + 10000
  for i in range(2, n+1):
    result = result * 0.00008 + result
  return result


>>> factorial(365)
10296.292974403043


原文地址:https://www.cnblogs.com/blogs-1024/p/11368011.html