GCC Code Coverage Report


Directory: ./
File: lib/my/my_is_prime.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 1 1 100.0%
Branches: 8 8 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_is_prime
4 ** File description:
5 ** Returns 1 if the number (nb) is prime and 0 otherwise
6 */
7 /**
8 * @file my_is_prime.c
9 * @brief The file containing the my_is_prime function
10 * @author Nicolas TORO
11 */
12
13 #include "my.h"
14
15 13 int my_is_prime(int nb)
16 {
17 13 int i = 0;
18
19
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
13 if (nb <= 1 || nb == 4) {
20 3 return 0;
21 }
22
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
18 for (i = 2; i < nb / 2; i++) {
23
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 8 times.
13 if (nb % i == 0) {
24 5 return 0;
25 }
26 }
27 5 return 1;
28 }
29