29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_sqrt.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/27 21:41:03 by ajoly #+# #+# */
|
|
/* Updated: 2022/08/01 15:57:14 by ajoly ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_sqrt(int nb)
|
|
{
|
|
int i;
|
|
|
|
i = 1;
|
|
while (i * i < nb && i <= nb / 2)
|
|
i++;
|
|
if ((nb % i) == 0)
|
|
return (i);
|
|
return (0);
|
|
}
|
|
|
|
#include <stdio.h>
|
|
int main()
|
|
{
|
|
printf("%d", ft_sqrt(__INT_MAX__));
|
|
} |