0

Hi This a very generic question. I Want to know can whether every Iterative method(using loops) can be done using recursion?

imp25
  • 2,327
  • 16
  • 23
user2059287
  • 15
  • 1
  • 8
  • 1
    YES !! :) Already answered here - http://stackoverflow.com/questions/2093618/can-all-iterative-algorithms-be-expressed-recursively – Pranay Agrawal Feb 01 '14 at 19:32

3 Answers3

0

I Want to know can whether every Iterative method(using loops) can be done using recursion?

Yes, see Church–Turing thesis, it proves this.

Useful links:

Maroun
  • 94,125
  • 30
  • 188
  • 241
0

Yes. Some great explanations can be found here.

Benjamin Bini
  • 311
  • 4
  • 15
0

Here is a generalized iterative function :-

for(int i=0;i<n;i++) {

   doSomething(i);

}

Here is equivalent recursive function :-

recfunc(int i,int n) {

  if(i<n) {

       doSomething(i); 
       recfunc(i+1,n);

  }

}
Vikram Bhat
  • 6,106
  • 3
  • 20
  • 19