-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_power.c
More file actions
32 lines (29 loc) · 1.08 KB
/
ft_power.c
File metadata and controls
32 lines (29 loc) · 1.08 KB
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_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abassibe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/17 14:39:28 by abassibe #+# #+# */
/* Updated: 2018/03/14 01:40:36 by abassibe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_power(int nb, int power)
{
int c;
int i;
c = 1;
i = nb;
if (power == 0)
return (1);
if (power == 1)
return (nb);
while (c < power)
{
i *= nb;
c++;
}
return (i);
}