asked 4.4k views
0 votes
Write a program that calculates how many days it takes to accumulate at least $1,000,000 if someone deposits one penny on the first day, two pennies the second day, four pennies on the third day and continues to double each day. The output should display the number of days

1 Answer

3 votes

Answer:

Explanation:

Let's do this in Python

day = 1

balance = 0

deposit = 0.01 # first deposit is 1 penny

while balance < 1000000: # execute the loop as long as balance is less than a million dollar

balance += deposit

deposit = deposit * 2 # double the deposit for the next time

day += 1 # add one to day for the next day

print(day) # print out result once loop ends

answered
User Koen Hendrikx
by
8.5k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.