-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_is_prime.c
30 lines (26 loc) · 1.04 KB
/
ft_is_prime.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_prime.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/26 14:50:24 by ana-lda- #+# #+# */
/* Updated: 2024/06/26 14:50:48 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_is_prime(int nb)
{
int n;
n = 2;
if (nb < 2)
return (0);
while (n <= (nb / n))
{
if (nb % n == 0)
return (0);
n++;
}
return (1);
}