All Euler problems
Project Euler

Fibonacci Golden Nuggets

Consider the infinite polynomial series A_F(x) = xF_1 + x^2F_2 + x^3F_3 +..., where F_k is the k -th term in the Fibonacci sequence: 1, 1, 2, 3, 5, 8,.... Find the 15th golden nugget, where a golde...

Source sync Apr 19, 2026
Problem #0137
Level Level 06
Solved By 6,491
Languages C++, Python
Answer 1120149658760
Length 294 words
sequencenumber_theoryalgebra

Problem Statement

This archive keeps the full statement, math, and original media on the page.

Consider the infinite polynomial series \(A_F(x) = x F_1 + x^2 F_2 + x^3 F_3 + \dots \), where \(F_k\) is the \(k\)th term in the Fibonacci sequence: \(1, 1, 2, 3, 5, 8, \dots \); that is, \(F_k = F_{k-1} + F_{k-2}\), \(F_1 = 1\) and \(F_2 = 1\).

For this problem we shall be interested in values of \(x\) for which \(A_F(x)\) is a positive integer.

Surprisingly \begin {align*} A_F(\tfrac {1}{2}) &= (\tfrac {1}{2})\times 1 + (\tfrac {1}{2})^2\times 1 + (\tfrac {1}{2})^3\times 2 + (\tfrac {1}{2})^4\times 3 + (\tfrac {1}{2})^5\times 5 + \cdots \\ &= \tfrac {1}{2} + \tfrac {1}{4} + \tfrac {2}{8} + \tfrac {3}{16} + \tfrac {5}{32} + \cdots \\ &= 2 \end {align*}

The corresponding values of \(x\) for the first five natural numbers are shown below.



\(x\) \(A_F(x)\)


\(\sqrt {2} - 1\) \(1\)


\(\frac {1}{2}\) \(2\)


\(\frac {\sqrt {13} - 2}{3}\) \(3\)


\(\frac {\sqrt {89} - 5}{8}\) \(4\)


\(\frac {\sqrt {34} - 3}{5}\) \(5\)


We shall call \(A_F(x)\) a golden nugget if \(x\) is rational, because they become increasingly rarer; for example, the \(10\)th golden nugget is \(74049690\).

Find the \(15\)th golden nugget.

Problem 137: Fibonacci Golden Nuggets

Mathematical Foundation

Theorem 1. The generating function has closed form AF(x)=x1xx2A_F(x) = \frac{x}{1 - x - x^2} for x<1φ|x| < \frac{1}{\varphi} where φ=1+52\varphi = \frac{1 + \sqrt{5}}{2}.

Proof. Let S=k=1FkxkS = \sum_{k=1}^\infty F_k x^k. Then xS+x2S=k=1Fkxk+1+k=1Fkxk+2xS + x^2 S = \sum_{k=1}^\infty F_k x^{k+1} + \sum_{k=1}^\infty F_k x^{k+2}. Using the Fibonacci recurrence Fk+2=Fk+1+FkF_{k+2} = F_{k+1} + F_k:

S=x+k=2Fkxk=x+k=2(Fk1+Fk2)xk=x+xS+x2SS = x + \sum_{k=2}^\infty F_k x^k = x + \sum_{k=2}^\infty (F_{k-1} + F_{k-2}) x^k = x + xS + x^2 S

Solving: S(1xx2)=xS(1 - x - x^2) = x, hence S=x1xx2S = \frac{x}{1 - x - x^2}. \square

Theorem 2. Setting AF(x)=nA_F(x) = n for a positive integer nn, the value xx is a positive real number if and only if 5n2+2n+15n^2 + 2n + 1 is a perfect square.

Proof. From n=x1xx2n = \frac{x}{1 - x - x^2}, rearranging: nx2+(n+1)xn=0nx^2 + (n+1)x - n = 0. By the quadratic formula:

x=(n+1)+(n+1)2+4n22n=(n+1)+5n2+2n+12nx = \frac{-(n+1) + \sqrt{(n+1)^2 + 4n^2}}{2n} = \frac{-(n+1) + \sqrt{5n^2 + 2n + 1}}{2n}

For xx to be real and positive, the discriminant D=5n2+2n+1D = 5n^2 + 2n + 1 must be a perfect square (and the positive root must be positive, which holds since D>n+1\sqrt{D} > n + 1 when D>(n+1)2D > (n+1)^2, i.e., 4n2>04n^2 > 0). \square

Theorem 3. The equation 5n2+2n+1=m25n^2 + 2n + 1 = m^2 reduces to the generalized Pell equation a25b2=4a^2 - 5b^2 = -4 via the substitution a=5n+1a = 5n + 1, b=mb = m.

Proof. Multiply 5n2+2n+1=m25n^2 + 2n + 1 = m^2 by 5: 25n2+10n+5=5m225n^2 + 10n + 5 = 5m^2, i.e., (5n+1)2+4=5m2(5n+1)^2 + 4 = 5m^2. Setting a=5n+1a = 5n + 1: a25m2=4a^2 - 5m^2 = -4. \square

Theorem 4. The kk-th golden nugget is nk=F2kF2k+1n_k = F_{2k} \cdot F_{2k+1}, where FjF_j is the jj-th Fibonacci number.

Proof. The generalized Pell equation a25b2=4a^2 - 5b^2 = -4 has solutions (ak,bk)(a_k, b_k) where ak+bk5=(1+5)(1+52)2k121(2k1)a_k + b_k\sqrt{5} = (1 + \sqrt{5}) \cdot \left(\frac{1 + \sqrt{5}}{2}\right)^{2k-1} \cdot 2^{1-(2k-1)}. More concretely, the solutions satisfy ak=L2k1a_k = L_{2k-1} (Lucas numbers) and bk=F2k1b_k = F_{2k-1} (Fibonacci numbers). However, we need a=5n+11(mod5)a = 5n + 1 \equiv 1 \pmod{5}. The solutions with a1(mod5)a \equiv 1 \pmod 5 correspond to even-indexed solutions of a filtered sequence, which yields nk=F2kF2k+1n_k = F_{2k} F_{2k+1}.

Verification:

  • k=1k = 1: n1=F2F3=12=2n_1 = F_2 \cdot F_3 = 1 \cdot 2 = 2. Check: 5(4)+4+1=255(4) + 4 + 1 = 25, 25=5\sqrt{25} = 5. Valid.
  • k=2k = 2: n2=F4F5=35=15n_2 = F_4 \cdot F_5 = 3 \cdot 5 = 15. Check: 5(225)+30+1=11565(225) + 30 + 1 = 1156, 1156=34\sqrt{1156} = 34. Valid.
  • k=3k = 3: n3=F6F7=813=104n_3 = F_6 \cdot F_7 = 8 \cdot 13 = 104. Check: 5(10816)+208+1=542895(10816) + 208 + 1 = 54289, 54289=233\sqrt{54289} = 233. Valid.

The pattern holds and can be proved by induction using the Fibonacci identity F2(k+1)F2(k+1)+1=F2k+2F2k+3F_{2(k+1)} F_{2(k+1)+1} = F_{2k+2} F_{2k+3} and the Pell solution recurrence. \square

Editorial

The k-th golden nugget is F(2k) * F(2k+1), where F is the Fibonacci sequence. Find the 15th golden nugget. We enumerate the admissible parameter range, discard candidates that violate the derived bounds or arithmetic constraints, and update the final set or total whenever a candidate passes the acceptance test.

Pseudocode

Compute F_{2k} * F_{2k+1}
Now F_prev = F_{2k}, F_curr = F_{2k+1}

Complexity Analysis

  • Time: O(k)O(k) arithmetic operations to compute Fibonacci numbers up to index 2k+12k + 1. Each operation involves big-integer addition, so with O(k)O(k) digits, the total bit complexity is O(k2)O(k^2).
  • Space: O(k)O(k) bits to store the Fibonacci numbers (which grow as φ2k\varphi^{2k}).

Answer

1120149658760\boxed{1120149658760}

Code

Each problem page includes the exact C++ and Python source files from the local archive.

C++ project_euler/problem_137/solution.cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    // The k-th golden nugget is F(2k) * F(2k+1)
    // We need the 15th, so we need F(30) * F(31)

    // Compute Fibonacci numbers up to F(31)
    long long fib[32];
    fib[1] = 1;
    fib[2] = 1;
    for (int i = 3; i <= 31; i++) {
        fib[i] = fib[i-1] + fib[i-2];
    }

    // 15th golden nugget = F(30) * F(31)
    long long answer = fib[30] * fib[31];
    cout << answer << endl;

    return 0;
}