Skip to content

Instantly share code, notes, and snippets.

@mebubo
Last active December 14, 2015 19:29
Show Gist options
  • Select an option

  • Save mebubo/5136801 to your computer and use it in GitHub Desktop.

Select an option

Save mebubo/5136801 to your computer and use it in GitHub Desktop.
человек кладет сумму Х на депозит под 10% годовых на 30 лет. и каждый год добавляет туда еще Х. сколько будет через 30 лет? пусть f(n) кол-во денег через n лет f(0) = x f(n) = 1.1*f(n-1) + x (для n>0)
#!/usr/bin/python
def f(n, x, coeff=0.1):
if n == 0:
return x
else:
return (1 + coeff) * f(n - 1, x, coeff) + x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment