Challenge: Cumulative Sum
Tâche
Swipe to start coding
Write a function that calculates the cumulative sum of all integers from 1 up to a given positive integer n using a for loop.
- Define a function named
cumulativeSumthat takes an integernas its parameter; - Use a for loop to add all numbers from 1 to
nand store the result; - Return the final sum from the function;
- Do not use any library functions for summation; implement the logic using a for loop only.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 3
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Génial!
Completion taux amélioré à 9.09
Challenge: Cumulative Sum
Glissez pour afficher le menu
Tâche
Swipe to start coding
Write a function that calculates the cumulative sum of all integers from 1 up to a given positive integer n using a for loop.
- Define a function named
cumulativeSumthat takes an integernas its parameter; - Use a for loop to add all numbers from 1 to
nand store the result; - Return the final sum from the function;
- Do not use any library functions for summation; implement the logic using a for loop only.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 3
single