24 lines
1.0 KiB
C
24 lines
1.0 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_sqrt.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2015/12/07 08:28:11 by gbrochar #+# #+# */
|
||
|
/* Updated: 2015/12/07 08:50:43 by gbrochar ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
long ft_sqrt(long n)
|
||
|
{
|
||
|
long sqrt;
|
||
|
|
||
|
sqrt = 0;
|
||
|
while ((sqrt * sqrt) != n && (sqrt * sqrt) < n)
|
||
|
sqrt++;
|
||
|
return (((sqrt * sqrt) == n) ? (sqrt) : (-1));
|
||
|
}
|