push
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_iterative_power.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sgongas <sgongas@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/02/22 22:53:07 by sgongas #+# #+# */
|
||||
/* Updated: 2026/02/22 23:12:14 by sgongas ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_iterative_power(int nb, int power)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (power < 0)
|
||||
return (0);
|
||||
if (power == 0 || nb == 0)
|
||||
return (1);
|
||||
res = nb;
|
||||
while (power-- > 1)
|
||||
res *= nb;
|
||||
return (res);
|
||||
}
|
||||
|
||||
// #include <stdio.h>
|
||||
// int main(void)
|
||||
// {
|
||||
// printf("%d\n", ft_iterative_power(5, 5));
|
||||
// return (0);
|
||||
// }
|
||||
Reference in New Issue
Block a user