Image for post
Image for post

To Understand Recursion, You Must First Understand Recursion

float _pow_recursion(float x, float y)
{
if (y == 0)
return (1);
if (y < 0)
return (_pow_recursion(x, y + 1) / x);
printf("Current x, y: %f, %f\n", x, y); return (_pow_recursion(x, y - 1) * x);
}
int main(void)
{
int res = 0;
res = _pow_recursion(2, 5);
printf("Result = %d\n", res);
return (0);
}
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Written by

Software Engineer | Linux | Cats | https://github.com/kai-dg | https://haruspace.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store