Give it an input and say what you think comes back. It compiles and runs for real, so a wrong guess still shows you the answer — probe as much as you like. Only correct predictions count.
Locked until you have predicted 4 outputs correctly.
| 1 | int solution(int n) { |
| 2 | int prev = 1; |
| 3 | int curr = 1; |
| 4 | for (int i = 1; i < n; i++) { |
| 5 | int next = prev + curr; |
| 6 | prev = curr; |
| 7 | curr = next; |
| 8 | } |
| 9 | return curr; |
| 10 | } |
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.