1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-2nd-piscine/C05/ex03/ft_recursive_power.c

23 lines
1.1 KiB
C
Raw Permalink Normal View History

2023-08-03 23:16:27 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_recursive_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/23 22:18:51 by adjoly #+# #+# */
/* Updated: 2023/07/25 19:41:15 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
int ft_recursive_power(int nb, int power)
{
if (power < 0)
return (0);
if (power == 0)
return (1);
if (power == 1)
return (nb);
return (ft_recursive_power(nb, power - 1) * nb);
}