-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathft_pwr.c
More file actions
32 lines (30 loc) · 1.13 KB
/
ft_pwr.c
File metadata and controls
32 lines (30 loc) · 1.13 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_pwr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mimeyer <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/06/11 14:28:56 by mimeyer #+# #+# */
/* Updated: 2019/06/11 15:30:19 by mimeyer ### ########.fr */
/* */
/* ************************************************************************** */
int ft_pwr(int base, int exponent)
{
int i;
int result;
i = 1;
result = base;
if (exponent == 0)
return (1);
if (exponent == 1)
return (result);
if (exponent < 0)
return (0);
while (i < exponent)
{
result *= base;
i++;
}
return (result);
}