GCC Code Coverage Report


Directory: ./
File: lib/my/my_compute_power_rec.c
Date: 2024-06-05 00:34:38
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_compute_power_rec
4 ** File description:
5 ** Returns the power (p) of the number (nb)
6 */
7 /**
8 * @file my_compute_power_rec.c
9 * @brief The file containing the my_compute_power_rec function
10 * @author Nicolas TORO
11 */
12
13 #include "my.h"
14
15 4311 int my_compute_power_rec(int nb, int p)
16 {
17 int result;
18
19
2/2
✓ Branch 0 taken 3187 times.
✓ Branch 1 taken 1124 times.
4311 if (p > 0) {
20 3187 result = nb;
21 3187 result = result * my_compute_power_rec(nb, p - 1);
22
2/2
✓ Branch 0 taken 1123 times.
✓ Branch 1 taken 1 times.
1124 } else if (p == 0) {
23 1123 result = 1;
24 } else {
25 1 result = 0;
26 }
27 4311 return result;
28 }
29