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