1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-1st-piscine/ended/C05/ex02/ft_iterative_power.c
2023-08-06 20:12:38 +02:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/27 16:42:03 by ajoly #+# #+# */
/* Updated: 2022/07/27 16:42:04 by ajoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_iterative_power(int nb, int power)
{
int i;
i = 1;
if (power < 0)
return (0);
else if (power == 0)
return (1);
while (power > 0)
{
i = i * nb;
power--;
}
return (i);
}