| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_compute_factorial_rec | ||
| 4 | ** File description: | ||
| 5 | ** Returns the factorial value of the number (nb) | ||
| 6 | */ | ||
| 7 | /** | ||
| 8 | * @file my_compute_factorial_rec.c | ||
| 9 | * @brief The file containing the my_compute_factorial_rec function | ||
| 10 | * @author Nicolas TORO | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "my.h" | ||
| 14 | |||
| 15 | 4 | int my_compute_factorial_rec(int nb) | |
| 16 | { | ||
| 17 |
3/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
|
4 | if (nb == 0 || nb == 1) { |
| 18 | 1 | return 1; | |
| 19 |
3/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
3 | } else if (nb > 1 && nb < 13) { |
| 20 | 2 | return nb * my_compute_factorial_rec(nb - 1); | |
| 21 | } else { | ||
| 22 | 1 | return 0; | |
| 23 | } | ||
| 24 | } | ||
| 25 |