Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 45

When Is The Next Centered Pentagonal Flag?

The 50 stars on the American flag form two rectangles because 5050 is twice a square, 2×252 \times 25. With statehood proposed for Washington, D.C., a 5151-star flag could place a star in the center surrounded by concentric pentagons of 5,10,155, 10, 15 and 2020 stars, a centered pentagonal number. So N=50N=50 has two nice properties at once: NN is twice a square and N+1N+1 is a centered pentagonal number. After 5050, what is the next integer NN with both properties?

The Riddler, FiveThirtyEight(original post)

Solution

We need N=2q2N = 2q^2 and N+1=5p2+5p+22N + 1 = \tfrac{5p^2 + 5p + 2}{2} for integers p,qp,q. Eliminating NN, 4q2+2=5p2+5p+24q^2 + 2 = 5p^2 + 5p + 2, so 4q2=5p(p+1)4q^2 = 5p(p+1), and after completing the square (x=2p+1x = 2p+1) this becomes x280y2=1,x=2p+1,  q=5y,x^2 - 80\,y^2 = 1, \qquad x = 2p+1,\ \ q = 5y, a Pell equation. Its fundamental solution is (x,y)=(9,1)(x,y) = (9,1), and the rest come from powers of 9+809 + \sqrt{80}: (9,1)(161,18)(2889,323).(9,1) \to (161,18) \to (2889,323) \to \cdots. The first solution gives p=4p=4, q=5q=5, N=50N = 50. The next, x=161x=161, gives p=80p = 80, q=90q = 90, so N=2902=16200,N = 2\cdot 90^2 = \boxed{16200}, with N+1=16201=5802+580+22N+1 = 16201 = \tfrac{5\cdot 80^2 + 5\cdot 80 + 2}{2}. (The one after that is 5,216,4505{,}216{,}450.)

The computation

Scan the centered pentagonal numbers: for each pp, form N=5p2+5p2N = \tfrac{5p^2+5p}{2} and keep those for which N/2N/2 is a perfect square (so NN is twice a square).

from math import isqrt
found = []
for p in range(1, 2000):
    N = (5*p*p + 5*p) // 2                 # N+1 is centered pentagonal
    if (5*p*p + 5*p) % 2 == 0 and N % 2 == 0:
        q2 = N // 2
        if isqrt(q2)**2 == q2:             # N = 2 * (perfect square)
            found.append(N)
print(found[:3])                            # [50, 16200, 5216450]