codekofi
← All problems

Problem 1

Easy

1 · Worked examples

0 / 4

Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.

solution()
returns

2 · Which problem is it?

Locked until you have predicted 4 outputs correctly.

The accepted solution

1int solution(int n) {
2
3 int prev = 1;
4 int curr = 1;
5
6 for (int i = 1; i < n; i++) {
7 int next = prev + curr;
8 prev = curr;
9 curr = next;
10 }
11
12 return curr;
13}

Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.