/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_recursive_power.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: whaffman +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/13 11:28:27 by whaffman #+# #+# */ /* Updated: 2024/06/13 11:32:29 by whaffman ### ########.fr */ /* */ /* ************************************************************************** */ #include int ft_recursive_power(int nb, int power) { int result; result = 1; if (power < 0) return (0); else if (power == 0) return (1); else return (nb * ft_recursive_power(nb, power - 1)); } #ifdef DEBUG int main(void) { int i; int j; i = -2; j = -2; while (i < 3) { while (j < 3) { printf("%d^%d = %d\n", i, j, ft_recursive_power(i, j)); j++; } j = -2; i++; } return (0); } #endif