Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

252
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda