Nathann Cohen wrote: > > Yo ! > > > This is good argument to support (only) []-style argument for several > > elements. Be consistent within same program. Or in Sage terms, "Build a > car, > > don't let it look like bicycle combined to tractor." :=) > > > > Btw, why gcd([]) returns zero? At least there is inconsistency with > lcm([]) > > returning one. I guess they should both return one or raise an > exception. > > I would say that it is because for guys doing number theory Z/2Z is > associated with 2 and Z is associated with 0. Think of 0 like the > infinity, or the product of all integers. >
Here is how I would put it: - sum([]) is zero because zero is the identity element for addition (for any x, the sum 0 + x equals x), therefore you can initialize a sum to 0, then add summands one by one, and this gets you the sum; so an empty sum is just the initial 0. - prod([]) is one because one is the identity element for multiplication (for any x, the product 1*x equals x); therefore you can initialize a product to 1, then multiply by the multiplicands one by one, and this gets you the product; so an empty product is just the initial 1. - gcd([]) is zero because zero is the identity element for gcd (for any x, gcd(0,x) equals x); therefore you can initialize a gcd to 0, then take gcd with the list elements one by one, and this gets you the gcd; so an empty gcd is just the initial 0. - lcm([]) is one because one is the identity element for lcm (for any x, lcm(1,x) equals x); therefore you can initialize an lcm to 1, then take lcm with the list elements one by one, and this gets you the lcm; so an empty lcm is just the initial 1. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.