first commit
This commit is contained in:
29
ended/C05/ex05/ft_sqrt.c
Normal file
29
ended/C05/ex05/ft_sqrt.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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__));
|
||||
}
|
Reference in New Issue
Block a user