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);
}
}
Notes
By definition of double factorial, the result is immediate.