Created
July 25, 2016 14:32
-
-
Save anonymous/ceb5efda41a52d69e7294a4b49e28871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VALUE factorials_num_double_factorial(VALUE num) | |
{ | |
long value = NUM2INT(num), result = 1; | |
if(value % 2 == 0) { | |
return INT2NUM( | |
pow(2, value / 2) * NUM2INT( | |
factorials_num_factorial(INT2NUM(value / 2)) | |
) | |
); | |
} else { | |
return INT2NUM( | |
NUM2INT(factorials_num_factorial(num)) / ( | |
pow(2, (value - 1) / 2) * NUM2INT( | |
factorials_num_factorial(INT2NUM((value - 1) / 2)) | |
) | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment