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
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---