ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 01 Feb 2019 04:06:01 -0600Product of elements in a sethttp://ask.sagemath.org/question/45261/product-of-elements-in-a-set/I have a set of numbers, and I would like to find the product of them. Generally speaking, the set of the numbers could be quite large, and will be complex, so I don't want to have to manually multiply them all. The example I have below only has 3 integer elements though..
v=[1,2,3]
S=Set(v)
S
c=S.cardinality()
c
My original thinking was something along the lines of:
P = prod(s[i] for i in range(1,c))
P
But I'm not sure how to:
1) define s[i] appropriately or
2) if this will work
I assume at some point I need to define I'm working in a complex field, but again, I'm not sure where I would need to do that?LukeC93Fri, 01 Feb 2019 04:06:01 -0600http://ask.sagemath.org/question/45261/