-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_maths.c
32 lines (28 loc) · 1.26 KB
/
ft_maths.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_maths.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: flfische <[email protected]. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/08 11:23:40 by flfische #+# #+# */
/* Updated: 2024/04/08 14:21:28 by flfische ### ########.fr */
/* */
/* ************************************************************************** */
int ft_lower_sqrt_search(int nb, int low, int high);
int ft_lower_sqrt(int nb)
{
if (nb <= 0)
return (0);
return (ft_lower_sqrt_search(nb, 0, nb));
}
int ft_lower_sqrt_search(int b, int low, int high)
{
int mid;
if (low == high)
return (low);
mid = (low + high) / 2;
if (mid * mid >= b)
return (ft_lower_sqrt_search(b, low, mid));
return (ft_lower_sqrt_search(b, mid + 1, high));
}