ft_sqrt.c 1.0 KB

12345678910111213141516171819202122232425
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_sqrt.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/01/28 22:43:47 by bchanot #+# #+# */
  9. /* Updated: 2018/10/11 23:12:24 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. size_t ft_sqrt(size_t nb)
  14. {
  15. size_t cpt;
  16. cpt = 0;
  17. if (nb == 0)
  18. return (false);
  19. while (cpt * cpt < nb)
  20. cpt++;
  21. return (cpt);
  22. }