A function can call any function — including itself. That is recursion: a function solves a problem by asking itself the same question about a smaller piece of it, until the piece is so small the answer is obvious.
The simplest example is a countdown. To count down from 3, say "3" — and then count down from 2. To count down from 2, say "2", then count down from 1… and when you reach 0, say "Go!" and stop:
countdown(3) prints 3 2 1 Go!. The function never loops — it calls itself
with a smaller number, and the call with 0 stops the chain.
A function that returns an answer
A recursive function can also return something. The factorial 5! = 5 · 4 · 3 · 2 · 1 is just 5 · 4!, and 4! is 4 · 3!, and so on down to 0!, which is 1. Each step hands the rest of the work to a smaller copy of the same problem:
fact(3) can't finish until it knows fact(2), which waits for fact(1),
which waits for fact(0). That last one answers immediately — and then the
answers travel back up: 1, then 1 · 1, then 2 · 1, then 3 · 2. Step through it
and watch the call-stack panel grow and shrink: