GCC Code Coverage Report


Directory: ./
File: lib/my/my_find_prime_sup.c
Date: 2024-06-05 00:29:21
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 2 2 100.0%
Branches: 11 12 91.7%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_find_prime_sup
4 ** File description:
5 ** Returns the next prime number starting form a number (nb)
6 */
7
8 5 static int is_prime(int nb)
9 {
10 5 int prime = 1;
11 5 int i = 0;
12
13
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
5 if (nb <= 0 || nb == 4) {
14 1 return 0;
15 }
16
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 for (i = 2; i < nb / 2; i++) {
17
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if (nb % i == 0) {
18 2 prime = 0;
19 }
20 }
21 4 return prime;
22 }
23
24 3 int my_find_prime_sup(int nb)
25 {
26 3 int i = 0;
27
28
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (nb <= 1) {
29 1 return 2;
30 }
31
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
5 while (is_prime(nb + i) == 0) {
32 3 i++;
33 }
34 2 return nb + i;
35 }
36