# Double Factorial

ID: 771; easy; 二阶阶乘

public class Solution {

/**

* @param n: the given number

* @return: the double factorial of the number

*/

public long doubleFactorial(int n) {

if (n == 0 || n == 1) return 1;

return (long)n * doubleFactorial(n - 2);

}

}

- By definition of double factorial, the result is immediate.

Last modified 1yr ago