I'm completely stuck here. Can you help code this R loop? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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

8th Oct 2021, 3:20 AM
Vince Richardson
Vince Richardson - avatar
2 Réponses
+ 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.
8th Oct 2021, 3:43 AM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
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
10th Nov 2021, 7:33 PM
Peter Roach
Peter Roach - avatar