View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12915 Members
Join this group to post and comment.
Preethi Raman
Preethi Raman • Dec 1, 2008

How to stop recursion function?

Can you plzz say me how to stop the recursion function
krishna_540
krishna_540 • Dec 2, 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
Generally the recursion function will quit based on the condition stated in the function or using a break statement or a return function
krishna_540
krishna_540 • Dec 2, 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
can u pls tell me the exact problem wher u want to break the function so that i can be more clear
Ashutosh_shukla
Ashutosh_shukla • Dec 2, 2008
Recursive functions always contain 2 parts.First that indicates action to be done by this call and second is the one that recursively calls the function again.We may specify condition that is to be satisfied for calling recursively or may also specify the condition of terminating the recursion process.
For eg: In factorial we continously call until the argument passed is 1 and when argument is 1 we simply return 1 so stop the recursion
Preethi Raman
Preethi Raman • Dec 2, 2008
Thanks a lot for your answer..and also does the recursion function forms
an infinite loop???
Its clear that we can terminate the recursive function either by a break,goto,and return functions..
komputergeek
komputergeek • Dec 3, 2008
break and goto are used to terminate loop.
komputergeek
komputergeek • Dec 3, 2008
Preethi Raman
does the recursion function forms
an infinite loop???
If you don't specify any statement to terminate,it will form infinite loop.

e.g
void func()
{
       func();
}
rscrbv
rscrbv • Dec 18, 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
i think u r not knowing correct concept of recursion
Given here in pseudocode:​
function factorial(n)
{
if (n<=1)
return 1;
else
return n * factorial(n-1);
}​
moksh
moksh • Dec 19, 2008
recursion function have a base condition ....

every time the function is called ... the value moves closer to he base condition....
Ahmad Suudi
Ahmad Suudi • Oct 20, 2014
Please try :

publicstaticvoidMain(string[]args)
{
tampil(10);
}

privatestaticvoidtampil(inti)
{
Console.WriteLine("Halo"+i.ToString());

if(i>0)
tampil(i-1);
}

Share this content on your social channels -