-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_power.c
26 lines (24 loc) · 1.04 KB
/
ft_power.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/21 16:27:49 by ylagtab #+# #+# */
/* Updated: 2020/03/02 21:31:43 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
long long ft_power(int nbr, unsigned int exp)
{
long long res;
res = 1;
while (exp > 0)
{
if (exp % 2 == 1)
res *= nbr;
exp >>= 1;
nbr *= nbr;
}
return (res);
}