-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_sqrt.c
29 lines (26 loc) · 1.05 KB
/
ft_sqrt.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_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mimeyer <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/06/11 14:58:31 by mimeyer #+# #+# */
/* Updated: 2019/06/17 09:02:28 by mimeyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
long ft_sqrt(long num)
{
long i;
if (num <= 0)
return (0);
i = 1;
while ((i * i) <= num)
{
if ((i * i) == num)
return (i);
i++;
}
return (0);
}