what is recursive function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is recursive function

31st Aug 2016, 4:15 PM
Romil
6 Answers
+ 3
As Cohen said, a recursive function is a function that calls itself, until it reaches a base case. Here is a concrete example: unsigned int factorial(unsigned int n) { if (n == 0) { return 1; } else { return n * factorial(n-1); } }
31st Aug 2016, 5:54 PM
Zen
Zen - avatar
+ 1
A recursive function is simply a function that calls itself. For example, if some code is running inside a function, and you want to return to the beginning of that function, perhaps with incremented values etc, you can call that function inside itself. You just used recurssion.
31st Aug 2016, 5:29 PM
Cohen Creber
Cohen Creber - avatar
+ 1
a function which calls itself until the terminating condition comes is known as recursive function... It uses stack to do recursion.
15th Sep 2016, 3:22 AM
Sawan Patidar
Sawan Patidar - avatar
0
"A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to "repeat the process".
31st Aug 2016, 4:25 PM
Leo
Leo - avatar
0
A recursive function (DEF) is a function which either calls itself or is in a potential cycle of function calls. As the definition specifies, there are two types of recursive functions. Consider a function which calls itself: we call this type of recursion immediate recursion.
1st Sep 2016, 2:30 AM
Talia
0
A recursive function is one that calls itself. Most useful is usually for sorting.
4th Sep 2016, 3:03 AM
GGA
GGA - avatar