28 lines
1.0 KiB
C
28 lines
1.0 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_is_prime.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/07/20 13:40:46 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/08/01 18:10:55 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
int ft_is_prime(int nb)
|
||
|
{
|
||
|
int i;
|
||
|
|
||
|
if (nb < 2)
|
||
|
return (0);
|
||
|
i = 2;
|
||
|
while (i <= nb / i)
|
||
|
{
|
||
|
if (nb % i == 0)
|
||
|
return (0);
|
||
|
i++;
|
||
|
}
|
||
|
return (1);
|
||
|
}
|