-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_power.c
executable file
·33 lines (31 loc) · 1.06 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
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mberger <mberger@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/08/04 22:22:48 by mberger #+# #+# */
/* Updated: 2014/08/06 11:59:47 by mberger ### ########.fr */
/* */
/* ************************************************************************** */
int ft_power(int nb, int power)
{
int result;
int i;
i = 0;
result = 1;
if (nb > 0)
{
while (i < power)
{
result *= nb;
i++;
}
}
else
{
result = 0;
}
return (result);
}