26 lines
1.1 KiB
C
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);
|
|
}
|