init
This commit is contained in:
25
C/c05v5/ex02/ft_iterative_power.c
Normal file
25
C/c05v5/ex02/ft_iterative_power.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
Reference in New Issue
Block a user