Recursive double factorial

Write a recursive function that returns @n@!!.

Recall that n!! = n × (n − 2) × (n − 4) × …. For instance,
9!! = 9 × 7 × 5 × 3 × 1 = 945 and 8!! = 8 × 6 × 4 × 2 = 384. By
definition, 0!! = 1!! = 1.

Interface

+-------:+:----------------------------------------------+
| C++    |     int double_factorial(int n);              |
+--------+-----------------------------------------------+
| C      |     int double_factorial(int n);              |
+--------+-----------------------------------------------+
| Java   |     public static int doubleFactorial(int n); |
+--------+-----------------------------------------------+
| Python |     double_factorial(n)  # returns int        |
+--------+-----------------------------------------------+
|        |     double_factorial(n: int) -> int           |
+--------+-----------------------------------------------+

Precondition

Assume 0≤ @n@  ≤ 19.

Observation

You only need to submit the required procedure; your main program will
be ignored.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:09:02.414Z

© Jutge.org, 2006–2026.
https://jutge.org
