Open In App

Getting Multiplication of the Objects passed as Arguments in R Language - prod() Function

Last Updated : 15 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
prod() function in R Language is used to return the multiplication results of all the values present in its arguments.
Syntax: prod(...) Parameters: ...: numeric or complex or logical vectors
Example 1: Python3
# R program to illustrate
# prod function

# Initializing some vectors of element
x <- c(1, 2, 3, 4)
y <- c(0, 2, 4, 6)
z <- c(2.6, 3.7, 1.9)

# Calling the prod() function
prod(x) # 1 × 2 × 3 × 4 
prod(y)
prod(z)
Output:
[1] 24
[1] 0
[1] 18.278
Example 2: Python3
# R program to illustrate
# prod function

# Calling the prod() function
prod(1:3) # 1 × 2 × 3
prod(0:8)
prod(2:6)
Output:
[1] 6
[1] 0
[1] 720

Similar Reads