Recursion and Inline Functions

Lesson 6 of 20

Watch a function call itself: every frame stacks up, the base case fires, and the answers climb back down.

The big picture

A function that calls itself

Recursion splits a problem into smaller copies of itself. Each call gets its own frame on the stack until the base case says stop.

The Big Idea

A recursive function calls itself on a smaller input until a base case stops the chain.

Base Case

The condition that ends the recursion — without it, the stack overflows and the program crashes.

Recursive Case

The branch that does one small piece of work and hands the rest to another call.

The Call Stack

Every call gets its own frame with its own n — frames stack up, then pop as answers return.

inline (C99)

Small helpers can be marked inline — a hint asking the compiler to paste the body at each call for speed.