42_C_PISCINE/C/c05v5/ex03/ft_recursive_power.c

21 lines
1.0 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_recursive_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 17:28:20 by cchauvet #+# #+# */
/* Updated: 2022/07/27 17:42:57 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_recursive_power(int nb, int power)
{
if (power < 0)
return (0);
if (power == 0)
return (1);
return (ft_recursive_power(nb, power - 1) * nb);
}