Challenge: Calculating Sum of Geometric Progression
In the previous chapter, we discovered a formula to calculate the sum of elements of an arithmetic progression. There is also a formula for the sum of a geometric progression:
Let's discover the following real-life case: consider a scenario where a population of bacteria doubles every hour. The initial population is 100 bacteria. We might want to calculate the total population after a certain number of hours. This scenario can be modeled as a geometric progression, where each term represents the population at a specific hour, and the common ratio r is 2 (since the population doubles each hour).
Swipe to start coding
Calculate the sum of first n elements of geometric progression using both for loop and the formula described above.
- Specify the arguments of the formula.
- Specify parameters of
forloop.
Once you've completed this task, click the button below the code to check your solution.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 4.76
Challenge: Calculating Sum of Geometric Progression
Desliza para mostrar el menú
In the previous chapter, we discovered a formula to calculate the sum of elements of an arithmetic progression. There is also a formula for the sum of a geometric progression:
Let's discover the following real-life case: consider a scenario where a population of bacteria doubles every hour. The initial population is 100 bacteria. We might want to calculate the total population after a certain number of hours. This scenario can be modeled as a geometric progression, where each term represents the population at a specific hour, and the common ratio r is 2 (since the population doubles each hour).
Swipe to start coding
Calculate the sum of first n elements of geometric progression using both for loop and the formula described above.
- Specify the arguments of the formula.
- Specify parameters of
forloop.
Once you've completed this task, click the button below the code to check your solution.
Solución
¡Gracias por tus comentarios!
single