1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-2nd-piscine/C05/ex06/ft_is_prime.c
2023-08-03 23:16:27 +02:00

30 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_prime.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/23 23:24:05 by adjoly #+# #+# */
/* Updated: 2023/08/02 10:20:17 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_is_prime(int nb)
{
int i;
if (nb <= 0 || nb == 1)
return (0);
i = 2;
if (nb == 2)
return (1);
while (i < nb / 2)
{
if (nb % i == 0)
return (0);
i++;
}
return (1);
}