Created
March 9, 2025 03:57
-
-
Save guidanoli/129d4073725c348db0e4228c436ef2fd to your computer and use it in GitHub Desktop.
Calculate discount of equal installments with zero interest
This file contains hidden or 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
| YEARLY_INTEREST = 0.1375 | |
| MONTHLY_INTEREST = ((1 + YEARLY_INTEREST) ** (1/12)) - 1 | |
| NUM_INSTALLMENTS = 12 | |
| print("+--------------+----------+") | |
| print("| Installments | Discount |") | |
| print("+--------------+----------+") | |
| installments = [1.0] | |
| for num_installments in range(1, NUM_INSTALLMENTS + 1): | |
| print("| {:12d} | {:7.3f}% |".format(num_installments, 100 * (1 - sum(installments) / num_installments))) | |
| installments.append(installments[-1] / (1 + MONTHLY_INTEREST)) | |
| print("+--------------+----------+") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment