Answer:
We will write 2 functions to calculate the number of doubles and triples that have occurred by a certain month and then call these functions at each step of our loop to calculate and output the payment for that month.
Step-by-step explanation:
def numberofdoubles(months):
return months DIV 2;
def numberoftriples(months):
return (months - 1) DIV 2;
n = input("How many months would you like to calculate payment for?");
for i in range(1 to n):
doublefactor = 2^(numberofdoubles(i))
triplefactor = 3^(numberoftriples(i))
payment = 1*doublefactor*triplefactor
print("Month " + i + ": R" + payment)