-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_power.c
30 lines (27 loc) · 1.08 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbopp <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/13 14:30:58 by lbopp #+# #+# */
/* Updated: 2016/11/13 14:42:20 by lbopp ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_power(int nb, int pow)
{
int result;
result = 1;
if (pow == 0)
return (1);
if (nb == 0)
return (0);
while (pow > 0)
{
result = result * nb;
pow--;
}
return (result);
}