← Back to archive

Stdle #96 · modern · 2026-09-10

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
int main() {
auto fib = [](int n) {
int a = 0, b = 1;
for (int i = 0; i < n; i++) {
int t = a + b;
a = b;
b = t;
}
return a;
};
std::cout << fib(10) << "\n";
}
Modern
4 attempts left

Answer & explanation