0
I'm completely stuck here. Can you help code this R loop?
Please help! Use a loop to calculate the sum of all numbers that are a multiple of 3 in the range of 1 to 1000. A number is a multiple of 3 if the remainder of dividing it by 3 is 0
2 ответов
+ 4
Hello, a quick review of loops in the R programming language will help you. I have never programmed in R before but I found the answer to your question in a matter of seconds. You want to check if 3%%X == 0, then add it to some value Y. Loop 1000 times. Very easy to do with a pen and paper, write it out first and then try to put that into practice.
0
I understand that's what you're trying to do, but how do you add it to the value Y for a single number readout?
EDIT: y=y+x