+ 1

Rangesum R Problem

I've been stuck for a few days with the rangeSum() problem in the R course. No matter what I write, I can't seem to get the answer right. Any help is welcome. Thanks!

15th Oct 2021, 4:57 PM
Gonzalo Rodríguez Hermida
Gonzalo Rodríguez Hermida - avatar
5 Antworten
+ 3
Don't reassign the iterator variable i in the loop! And only print the sum once after the loop (not inside the loop)
16th Oct 2021, 4:06 PM
Lisa
Lisa - avatar
+ 2
Please show your code! Then we can help you to solve it
15th Oct 2021, 5:25 PM
Lisa
Lisa - avatar
+ 2
Gonzalo Rodríguez Hermida I completed that challenge. Show us your code so far and we will help you. I will give you a hint. I used a for loop... for(n in a:b)
15th Oct 2021, 9:29 PM
Paul K Sadler
Paul K Sadler - avatar
+ 1
This is my code so far. I can't seem to make it not print all the other sums, apart from the message Error in rangeSum(x, y) : could not find function "rangeSum" popping up constantly sum = 0 for (i in x:y) { sum = sum+i i = x print(sum) }
16th Oct 2021, 4:04 PM
Gonzalo Rodríguez Hermida
Gonzalo Rodríguez Hermida - avatar
0
Thank you very much!!!
16th Oct 2021, 4:08 PM
Gonzalo Rodríguez Hermida
Gonzalo Rodríguez Hermida - avatar