+ 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
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
0
Wait I used the wrong language xD…
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.
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.