+ 4
Can somebody explain the recursive functions with details?
I red it's definition but didn't understand
10 Réponses
+ 3
look recursive function is a function, which calls himself until the condition is true. For example:
int name(int num) {
if (num == 1)
return 1;
return num+name(num-1);
}
if we pass lets say 3 to it, it will return 3+2+1
+ 3
Hey brother check this.you can understand how recursion works.
https://www.sololearn.com/discuss/1149517/?ref=app
+ 2
Great question Otabek Karimov
+ 1
Recursion is where a method calls itself. this is useful where you may want to loop recursively vs looping iteratively (like standard for loop)
int factorial(int num)
{
if(num == 1)
return 1;
return factorial(num - 1) * num;
}
This example recursively finds the factorial of "num"
+ 1
yea I see that now
+ 1
Thank you for explaining
+ 1
Recursive function simply known as repeated function.
It's used for repeated function execution in program.
Example factorial numbe.
It's calls the function when condition is true another way return the value.
0
That's funny that we had the same idea, I didn't see the post until after I posted mine haha
0
John yea ) the most common case to learn is factorial, I’ve tried to explain a bit easier )
0
my example is not computing factorial ))