On 27 October 2014 12:37, Nathann Cohen <nathann.co...@gmail.com> 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. >
It is not inconsistent, any more than this is: sage: sum([]) 0 sage: prod([]) 1 and the reason is essentially the same. > 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. I don't quite follow that but as a number theorist here is how I would explain it. If you write a loop to read in integers and output their sum, you just add each new one to the runing total, after initializing this total to: 0 Same but for products: you have to initialize to 1. Same but for gcd: each updated result is the gcd of the running "total" and the new input. Must be initialised to: 0. Same for lcm: each time you take the lcm with the new input. To get the right answer you must initialize to: 1. In every vase this tells you what f([]) should be! John > > Nathann > > -- > 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. -- 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.