Skip to content

Commit

Permalink
Say no to betty, add info"
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeJnr committed Jun 8, 2023
1 parent fa7f112 commit 0c10aee
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions 0x08-recursion/4-pow_recursion.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
#include "main.h"

/**
* _pow_recursion - calculate the power of a number to a degree
* @x: The base number
* @y: The power
*
* Return: Error is (-1), recursively calculates the power
*
* Author: Destiny Saturday (DestinedCodes)
* Date: 08/06/2023
*/

int _pow_recursion(int x, int y)
{
if (y < 0)
{
return(-1);
return (-1);
}
else if (y == 0)
{
return(1);
return (1);
}
else if (y == 1)
{
return(x);
return (x);
}
else
{
return(x * _pow_recursion(x, y - 1));
return (x * _pow_recursion(x, y - 1));
}
}

0 comments on commit 0c10aee

Please sign in to comment.