Last active
July 18, 2016 12:19
-
-
Save suvojit-0x55aa/dc2ca3c55cac0284198b05d4aa25a860 to your computer and use it in GitHub Desktop.
The power of compounding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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