Ask Your Question

Revision history [back]

SymPy's product function does transform that particular symbolic product into the factorial:

sage: from sympy import product, symbols
sage: i, n = symbols('i, n')
sage: product(i, (i, 1, n-1))
factorial(n - 1)

It makes me think that for prod it is a feature which hasn't been implemented but perhaps i'm mistaken. Note that sum has a nicer behavior: for instance sum(1/i, i, 1, n) returns harmonic_number(n).

One alternative is not using prod but just factorial(n-1), as already suggested by kcrisman. Another alternative is to define a Python's lambda function (more on this here), as in:

sage: someProduct = lambda n : prod([i for i in range(1, n)])
sage: someProduct(10)
362880