26 lines
1.1 KiB
C
26 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_recursive_power.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2016/10/29 14:57:08 by gtertysh #+# #+# */
|
||
|
/* Updated: 2016/10/31 15:46:31 by gtertysh ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
int ft_recursive_power(int nb, int power)
|
||
|
{
|
||
|
if (power < 0)
|
||
|
{
|
||
|
return (0);
|
||
|
}
|
||
|
else if (power == 0)
|
||
|
{
|
||
|
return (1);
|
||
|
}
|
||
|
nb = ft_recursive_power(nb, power - 1) * nb;
|
||
|
return (nb);
|
||
|
}
|