total. Write it as a sum of Fibonacci numbers using as few terms as possible and return how many terms you used. The same Fibonacci number may appear more than once.
Such a sum exists for every positive total.total=12 → 3
The Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, … We get 12 = 8 + 3 + 1, and one or two terms are not enough.
total=16 → 2
16 = 13 + 3, so two terms suffice.
total=21 → 1
21 is itself a Fibonacci number.
total ≤ 10⁹total=12
3
Run checks the first 3 tests in your browser. Submit checks all 68 tests on the server, hidden ones included.