42_C_PISCINE/C/c05v4/ex05/ft_sqrt.c

26 lines
1014 B
C
Raw Permalink Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/25 17:33:47 by cchauvet #+# #+# */
/* Updated: 2022/07/25 17:35:41 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_sqrt(int nb)
{
int i;
i = 1;
while (i <= nb / i)
{
if (i * i == nb)
return (i);
i++;
}
return (0);
}