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