Click to show/hide code
<- function(n) { # create a function with n as an argument
product_series <- 1 # create an empty variable to store the product result with 1 as an initial value
result for (i in 2:n) { # set for loop to iterate from 2 to n
<- result * (i+1) # multiply the value of i+1 by the result variable
result
}return(result) # return the final value of result
}
product_series(5)
[1] 360