27 lines
1.0 KiB
C
27 lines
1.0 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_iterative_power.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2021/08/18 10:51:08 by gbaconni #+# #+# */
|
|
/* Updated: 2021/08/18 10:51:14 by gbaconni ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_iterative_power(int nb, int power)
|
|
{
|
|
int n;
|
|
|
|
if (power < 0)
|
|
n = 0;
|
|
else if (power == 0)
|
|
n = 1;
|
|
else
|
|
n = nb;
|
|
while (power > 0 && --power)
|
|
n *= nb;
|
|
return (n);
|
|
}
|