27.36 Product

Product( list )
Product( list, func )

In the first form Product returns the product of the elements of the list list, which must have no holes. If list is empty, the integer 1 is returned.

In the second form Product applies the function func to each element of the list list, which must have no holes, and multiplies the results. If the list is empty, the integer 1 is returned.

    gap> Product( [ 2, 3, 5, 7, 11, 13, 17, 19 ] );
    9699690
    gap> Product( [1..10], x->x^2 );
    13168189440000
    gap> Product( [ (1,2), (1,3), (1,4), (2,3), (2,4), (3,4) ] );
    (1,4)(2,3) 

Sum (see Sum) computes the sum of the elements of a list.

Previous Up Top Next
Index

GAP 3.4.4
April 1997