brando
brando

Reputation: 15

Can any method that uses a loop be written recursively?

I know that any recursive method can be written in a way that uses loops (instead of recursion), but can any given iterative method be written recursively?

Upvotes: 1

Views: 470

Answers (1)

Jeff Crowell
Jeff Crowell

Reputation: 122

yes, it can! This may seem a bit circular in logic, but there are languages that are 100% turing complete with only iterative structure and others that are only recursive structures.

Therefore the two must be equivalent.

Upvotes: 1

Related Questions