Skip to content

Commit

Permalink
PLD in a min
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeJnr committed Jun 8, 2023
1 parent df57375 commit f9c993e
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions 0x08-recursion/5-sqrt_recursion.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
#include "main.h"

int _square_div(int i)
int _square_div(int num, int i)
{

if (num % (i*i))
{
return (1);
}
else
{
_square_div(num, i+1);
}
}




int _sqrt_recursion(int n)
{
if (n < 0)
{
return (-1);
}
else if (n == 0)
{
return (0);
}
else
{
j = _square_div(i +1)
return (_sqrt_recursion(n / (j * j));
}
if (n < 0)
{
return (-1);
}
else if (n == 0)
{
return (0);
}
else if (n == 1)
{
return (1);
}
else
{
j = _square_div(2)
return (_sqrt_recursion(n / (j * j));
}
}

0 comments on commit f9c993e

Please sign in to comment.