+ 1

sum of all numbers that are a multiple of 3 in the range of 1 to 1000 , by using a loop, please help🙏

Help for understand of answer a question

4th Jul 2022, 2:04 PM
Claire
Claire - avatar
4 odpowiedzi
+ 3
x = 0 sum = 0 y = 0 while x < 1000: x = 3 * y if x < 1000: sum += y y += 1 print(sum) This should work… You do y*3 until y*3 is more than 1000
4th Jul 2022, 2:29 PM
Janne
Janne - avatar
0
Wait I used the wrong language xD…
4th Jul 2022, 2:33 PM
Janne
Janne - avatar
0
Janne Pls don't give finished code as answer. Prefer giving hints for the OP to find the solution. Let's help others learning.
4th Jul 2022, 5:38 PM
Emerson Prado
Emerson Prado - avatar
0
L... Loop through the range, test if number is multiple of 3, and add it to final sum if it is. If you have difficulties, include in the question description a link to your code in Code Playground and an explanation of your difficulties.
4th Jul 2022, 5:40 PM
Emerson Prado
Emerson Prado - avatar