Skip to content

Instantly share code, notes, and snippets.

@suvojit-0x55aa
Last active July 18, 2016 12:19
Show Gist options
  • Save suvojit-0x55aa/dc2ca3c55cac0284198b05d4aa25a860 to your computer and use it in GitHub Desktop.
Save suvojit-0x55aa/dc2ca3c55cac0284198b05d4aa25a860 to your computer and use it in GitHub Desktop.
The power of compounding
__author__ = 'Suvojit Manna'
try:
p = float(raw_input())
r = float(raw_input())
t = int(raw_input())
ans = p
r /= 12*100
for i in xrange(1, t):
ans *= 1 + r
ans += p
print ans
print int(round(ans))
except Exception as e:
print("Invalid Input")
__author__ = 'Suvojit Manna'
from decimal import *
try:
p = Decimal(raw_input())
r = Decimal(raw_input())
t = int(raw_input())
ans = p
r = Decimal(r / 1200)
for i in xrange(1, t):
ans = Decimal(ans) * Decimal(1 + r)
ans = Decimal(ans + p)
print ans
print int(round(ans))
except Exception as e:
print("Invalid Input")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment