{}
run-icon
main.r
# R Programming - Sum of elements in a vector nums <- c(2, 4, 6, 8) sum <- 0 for (n in nums) { sum <- sum + n } print(sum)
Output