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