All examples

Fibonacci (recursion), .

Classic exponential recursion - fib(n) = fib(n-1) + fib(n-2).

fibonacci.js
function fib(n) {
  if (n < 2) return n;
  return fib(n - 1) + fib(n - 2);
}

fib(6);

What to watch

The call stack grows tall with nested function boxes; each returns its value as its frame pops.

Reading fibonacci (recursion)on a page only gets you so far - code is a process, and the process happens at runtime where you can't normally see it. In NeonFlow, this exact program runs step by step: every call opens a frame, every branch picks a path, and every value moves through memory in front of you. That's the fastest way to actually understand how fibonacci (recursion) works.

Run fibonacci (recursion) yourself

Open NeonFlow, paste this code (or any of your own), and scrub through it one step at a time.

Open NeonFlow