-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_isprime.c
29 lines (27 loc) · 1.06 KB
/
ft_isprime.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_isprime.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/16 18:22:26 by igarbuz #+# #+# */
/* Updated: 2018/11/16 18:48:36 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
int ft_isprime(long int i)
{
long int d;
if (i < 2)
return (0);
if (i == 2 || i == 3)
return (1);
d = 2;
while (d * d <= i)
{
if (i % d == 0)
return (0);
d++;
}
return (1);
}