-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_sqrt.c
25 lines (23 loc) · 1.03 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hezzahir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/16 21:27:43 by hezzahir #+# #+# */
/* Updated: 2018/11/16 22:52:00 by hezzahir ### ########.fr */
/* */
/* ************************************************************************** */
int ft_sqrt(int nb)
{
int sqrt;
if (nb < 0)
return (0);
sqrt = 1;
while (sqrt * sqrt < nb)
++sqrt;
if (sqrt * sqrt == nb)
return (sqrt);
return (0);
}