-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_iterative_power.c
29 lines (27 loc) · 1.14 KB
/
ft_iterative_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
27
28
29
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_iterative_power.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/10/23 13:15:43 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/23 13:18:02 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
int ft_iterative_power(int nb, int power)
{
int x;
x = nb;
if (power < 0)
return (0);
if (power == 0)
return (1);
while (power > 1)
{
nb = nb * x;
power--;
}
return (nb);
}