On Tue, 26 Aug 2008, William Stein wrote: > > On Tue, Aug 26, 2008 at 5:34 PM, Jason Merrill <[EMAIL PROTECTED]> wrote: >> >> I couldn't find a double factorial function in sage. That is, >> >> n!! == n*(n - 2)*(n - 4)... >> >> Does Sage have a double factorial somewhere that I'm missing. If not, >> could it? >> > > I had to write this for Pynac. Here's the 1-liner that does it... > > def doublefactorial(x): > n = Integer(x) > if n < -1: > raise ValueError, "argument must be >= -1" > return prod([n - 2*i for i in range(n//2)]) > > sage: doublefactorial(20) > 3715891200
Yes, Integers have a (highly optimized) multifactorial method. sage: a = 20 sage: a.multifactorial(2) 3715891200 - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---