1. Member
Join Date
Jul 2011
Posts
5
Rep Power
0

## Racking my brain

I have been racking my brain for the past 2 1/2 hours trying to figure this out, I need to write a program to calculate and print the number of weeks that it will take to reach a total of one million dollars or greater if you are exponentially increases your money each week, meaning you have a penny the first week, then two pennies the next and four pennies the third week. Any ideas or help would be appreciated that will get me started. I know I have to write a while statement, but that is about all I know at this point.

2. Inside the loop increment a count, increment money value. Surely it is not that hard to work out what the condition of the while loop is.

3. What steps would you take if you had to solve it on paper without using Java? Often that's the best way to start a problem like this because it can get you to a workable algorithm.

4. Originally Posted by beauti477
I have been racking my brain for the past 2 1/2 hours trying to figure this out, I need to write a program to calculate and print the number of weeks that it will take to reach a total of one million dollars or greater if you are exponentially increases your money each week, meaning you have a penny the first week, then two pennies the next and four pennies the third week. Any ideas or help would be appreciated that will get me started. I know I have to write a while statement, but that is about all I know at this point.
Are you allowed to solve the problem without using a loop? If so, note that the number of pennies is functionally dependent on the number of weeks, i.e. p= pow(2, w) where p and w are the number of pennies and the week number starting at zero. So, if you want to know w where p == 1000000 --> w = 2log(1000000), so w =~ 20.

kind regards,

Jos

5. Bloody mathematicians!

6. Originally Posted by Junky
Bloody mathematicians!
I only trust them as far as I can throw a rock at them.

kind regards,

Jos ;-)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•