mirror of
https://github.com/Ladebeze66/Piscine42.git
synced 2025-12-16 05:58:07 +01:00
31 lines
1.0 KiB
C
Executable File
31 lines
1.0 KiB
C
Executable File
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_is_prime.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/12/12 18:55:02 by fgras-ca #+# #+# */
|
|
/* Updated: 2022/12/13 13:38:38 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_is_prime(int nb)
|
|
{
|
|
int i;
|
|
|
|
i = 2;
|
|
if (nb <= 1)
|
|
return (0);
|
|
while (i <= nb / 2)
|
|
{
|
|
if (nb % i == 0)
|
|
{
|
|
return (0);
|
|
}
|
|
else
|
|
i++;
|
|
}
|
|
return (1);
|
|
}
|