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:
x < - c( 1 , 2 , 3 , 4 )
y < - c( 0 , 2 , 4 , 6 )
z < - c( 2.6 , 3.7 , 1.9 )
prod(x)
prod(y)
prod(z)
|
Output:
[1] 24
[1] 0
[1] 18.278
Example 2:
prod( 1 : 3 )
prod( 0 : 8 )
prod( 2 : 6 )
|
Output:
[1] 6
[1] 0
[1] 720