0

R - rangeSum

The code to the problem is not getting resolved: Always gives the error input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) #define the function rangeSum <- function(a,b){ sum <- 0 for (i in a:b) { sum <- sum + i } return sum } result <- rangeSum(x, y) print(result)

7th Mar 2023, 12:42 PM
Saju Sukumar
Saju Sukumar - avatar
1 Antwort
+ 2
Note that it is return(sum), not return sum
7th Mar 2023, 1:22 PM
Lisa
Lisa - avatar