-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_sqrt.c
33 lines (30 loc) · 1.09 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
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rnarciso <rnarciso@student.42lisboa.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 04:16:05 by rnarciso #+# #+# */
/* Updated: 2022/09/27 02:50:39 by rnarciso ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
int ft_sqrt(int nb)
{
int i;
i = 1;
if (nb > 0)
{
while (i * i <= nb)
{
if (i * i == nb)
return (i);
if (i >= 46341)
return (0);
i++;
}
}
return (0);
}