Skip to content

Instantly share code, notes, and snippets.

@suvojit-0x55aa
Last active Jul 18, 2016
Embed
What would you like to do?
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