product

function product( x, ... ) --> res

Description

Computes the product of x with all the additional value ().

Parameters

x

The first number you want to add to the product.

An variable number of values that will be multiplied with x.

Return Values

res

The calculated product value.

Code

--ZFUNC-product-v1
local function product( x, ... ) --> res
   local res = x
   for _, v in ipairs{ ... } do
      res = res * v
   end
   return res
end

return product

Examples

local t = require( "taptest" )
local product = require( "product" )

t( product( 5, 15, 30 ), 2250 )
t( product( 5, 15, 30, 2 ), 4500 )

t()

Inspired by