s is defined by these rules:
- s[0] = 0 and s[1] = 1;
- for an even index 2k ≥ 2: s[2k] = s[k];
- for an odd index 2k + 1 ≥ 3: s[2k + 1] = s[k] + s[k + 1].
Given a number last, return the largest value among the terms s[0], s[1], …, s[last].last=9 → 4
Terms 0 through 9 are 0, 1, 1, 2, 1, 3, 2, 3, 1, 4. For instance, s[9] = s[4] + s[5] = 1 + 3 = 4. The largest is 4.
last=4 → 2
The sequence is 0, 1, 1, 2, 1, so the maximum is 2.
last=0 → 0
last=9
4
Run checks the first 3 tests in your browser. Submit checks all 34 tests on the server, hidden ones included.