42_C_PISCINE/C/c05v4/ex02/ft_iterative_power.c
Camille Chauvet 29ed24d567 init
2023-05-17 16:45:25 +00:00

26 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 17:17:04 by cchauvet #+# #+# */
/* Updated: 2022/07/26 16:55:22 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_iterative_power(int nb, int power)
{
int nbr_out;
if (power < 0)
return (0);
if (power == 0)
return (1);
nbr_out = nb;
while (--power > 0)
nbr_out = nbr_out * nb;
return (nbr_out);
}