P297
projecteuler.net

Zeckendorf Representation

ℹ️Published on Friday, 18th June 2010, 05:00 pm; Solved by 3046;
Difficulty rating: 35%

Each new term in the Fibonacci sequence is generated by adding the previous two terms.
Starting with $1$ and $2$, the first $10$ terms will be: $1, 2, 3, 5, 8, 13, 21, 34, 55, 89$.

Every positive integer can be uniquely written as a sum of nonconsecutive terms of the Fibonacci sequence. For example, $100 = 3 + 8 + 89$.
Such a sum is called the Zeckendorf representation of the number.

For any integer $n \gt 0$, let $z(n)$ be the number of terms in the Zeckendorf representation of $n$.
Thus, $z(5) = 1$, $z(14) = 2$, $z(100) = 3$ etc.
Also, for $0 \lt n \lt 10^6$, $\sum z(n) = 7894453$.

Find $\sum z(n)$ for $0 \lt n \lt 10^{17}$.



Soluzione

Last modified: May 01, 2025. Website built with Franklin.jl and the lovely Julia programming language.