Back to discover
Computer ScienceMathematics

What is recursion and why does it work?

Asked by Dev A.·2 days ago·372 people helped

Explanation depth

Academic perspective

JP

Jules P.

Bootcamp mentor

Computer Science

Imagine standing in a line and you want to know your position. You can't see the front, so you tap the person ahead and ask 'what number are you?' They ask the person ahead of them, and so on.

The person at the very front knows their number is 1 — that's the stopping point. Then everyone adds one and passes the answer back. That passing-the-question-forward and answers-coming-back is recursion.

140 people understood this

Still not clicking? Ask a different person to explain it another way.