+ 1
Can anyone explain me recursive function?
I am newbie, learning java programming.
4 Answers
+ 1
Recursion is used when you have a big problem and the solution to it is a smaller problem and this goes on. For eg take the factorial problem, to find 5's factorial you need a 4's factorial and to find a 4's factorial you need a 3's factorial and so on until you get your final result.
+ 1
Try read this.
https://code.sololearn.com/cSC06PGFp49R/?ref=app
0
Recursive function is a function which calls itself repeatedly certain number of times.
For ex: print n to 1 numbers.
void print(int n)
{
if(n>0)
{
System.out.println(n);
print(--n); //recursively calling from n to 0;
}
If n=10, then it prints 10 to 1 numbers
By calling print(10),print(9),print(8)....print(0).
0
recursive consists of calling the function inside of itself