Skip to content

Commit

Permalink
Power as powerful
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeJnr committed Jun 8, 2023
1 parent 1da9a1e commit fa7f112
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 0x08-recursion/4-pow_recursion.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "main.h"

int _pow_recursion(int x, int y)
{
if (y < 0)
{
return(-1);
}
else if (y == 0)
{
return(1);
}
else if (y == 1)
{
return(x);
}
else
{
return(x * _pow_recursion(x, y - 1));
}
}
1 change: 1 addition & 0 deletions 0x08-recursion/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ void _puts_recursion(char *s);
void _print_rev_recursion(char *s);
int _strlen_recursion(char *s);
int factorial(int n);
int _pow_recursion(int x, int y);

#endif/*MAIN_H*/

0 comments on commit fa7f112

Please sign in to comment.