Code Playground

Learn by doing, explore by experimenting

😄
"Why do programmers prefer dark mode? Because light attracts bugs!"
Fibonacci Generator
function fibonacci(n, memo = {}) {
  if (n in memo) return memo[n];
  if (n <= 1) return n;
  
  memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo);
  return memo[n];
}

// Generate first 20 Fibonacci numbers
for (let i = 0; i < 20; i++) {
  console.log(`F(${i}) = ${fibonacci(i)}`);
}

📊 Complexity Analysis

Time Complexity:O(n)
Space Complexity:O(n)

With memoization, we store each computed value, so each number is calculated only once.

Output
Click "Run Code" to see the output

🎮 Interactive Features

Try pressing the Konami code: ↑↑↓↓←→←→BA

Or explore the different code examples above!