feat(math/sqrt): adding a function to calculate square root

This commit is contained in:
Raphael 2025-09-17 16:43:00 +02:00
parent c27526bc24
commit 62dec89863
No known key found for this signature in database

28
math/ft_sqrt.c Normal file
View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/17 16:30:27 by rparodi #+# #+# */
/* Updated: 2025/09/17 16:37:00 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdint.h>
#include <stdio.h>
uint64_t ft_sqrt(uint64_t nb)
{
uint64_t i;
i = 1;
while ((i * i) <= nb && i <= 4294967296)
{
if ((i * i) == nb)
return (i);
i++;
}
return (0);
}