Archived
first commit
This commit is contained in:
1 parent
7f3254f1c5
commit
a80c4d61d7
133 files changed
+4293
No files matched your search
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in new issue
Block a user