Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
Daily earnings doubling each day - starting at 1 cent for 30 days

Trying to calculate daily earning if $ is doubled each day- starting at one cent. I have most of it going except on day 1 I get 2 cents where it should be 1 cent.

<script>
var money = 1;

 
for (var i = 1; i < 31; i++) {

money = money * 2;

total = money /100;

document.writeln("<p>After day " + i + " you will have " + money + " cents.</p>");

}

document.writeln("<p>In thirty days you will have earned $" + total + ".</p>");

</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

        var money = 1;
        var total = 0;
        
        for (var i = 1; i < 31; i++) {
           // as you've already set the money for the 1st day, start the calculating loop from the 2nd day
           if(i = 1){
               total = money /100;
        
               document.writeln("<p>After day " + i + " you will have " + money + " cents.</p>");
           }else{
               money = money * 2;
        
               total = money /100;
        
               document.writeln("<p>After day " + i + " you will have " + money + " cents.</p>");
           }
        
        
        }
        
        document.writeln("<p>In thirty days you will have earned $" + total + ".</p>");
        

as you've already set the money for the 1st day, start the calculating loop from the 2nd day

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!