My problem is that I usually get a java.lang.StackOverflowError when I use recursion. My question is - why does recursion cause stackoverflow so much more than loops do, and
Here for loop is used inside the recursive function. When the recursive function is called, for(int i=0; i
Solution: Avoid for loop inside recursive function; instead go for while or do-while and initialize the value of i outside recursive function