## Problem

Here is this week’s Riddler’s Classic

Just in time for the Fourth of July, this week’s Classic is about stars on the American flag:

The \(50\) stars on the American flag are arranged in such a way that they form two rectangles. The larger rectangle is \(5\) stars wide, \(6\) stars long; the smaller rectangle is embedded inside the larger and is \(4\) stars wide, \(5\) stars long. This square-like pattern of stars is possible because the number of states \((50)\) is twice a square number \((25)\).

Now that the House of Representatives has passed legislation that would make the District of Columbia the fifty-first US state — and renamed Washington, Douglass Commonwealth, in honor of Frederick Douglass — a natural question is how to aesthetically arrange \(51\) stars on the flag.

One pleasing design has a star in the middle, surrounded by concentric pentagons of increasing side length, as shown below. The innermost pentagon has five stars, and subsequent pentagons are made up of 10, 15 and 20 stars. All told, that’s 51 stars.

It just so happens that when \(N\) equals \(50\), \(N\) is twice a square and \(N+1\) is a centered pentagonal number. After \(50\), what is the next integer \(N\) with these properties?

## Solution

We are looking for an \(N\) that satisifies the following:

\[ \begin{align*} N + 1 &= \frac{5p^2+5p+2}{2} \\ N &= 2q^2 \end{align*} \]

for some integers \(p\) and \(q\).

From the above we have \(5(2p+1)^2 - 5 = 16q^2\) or \(x^2 - 80q^2 = 1\) where \(x=2p+1\) and \(q=5y\).

The equation \(x^2 - 80y^2 = 1\) is a **Pell’s equation**.

If \((x,y)=(u,v)\) is a solution of the above equation, a whole family of solutions can be found by taking each side to the \(n^{th}\) power ,

\[ x^2 - 80y^2 = (u^2 - 80v^2)^n = 1. \]

Factoring gives,

\[ x + \sqrt{80}y = (u + \sqrt{80}v)^n \\ x - \sqrt{80}y = (u - \sqrt{80}v)^n \]

which gives the whole family of solutions

\[ x = \frac{(u + v\sqrt{80})^n + (u - v\sqrt{80})^n}{2}\\ y = \frac{(u + v\sqrt{80})^n - (u - v\sqrt{80})^n}{2\sqrt{80}} \]

It is easy to see that \((u,v)=(9,1)\) is a solution to \(x^2 - 80y^2=1\).

For \(n=1\), we have \(x=9\), therefore \(p=4\) and \(N=50\). For \(n=2\), we have \(x=161\), therefore \(p=80\) and \(N=16200\).

## Brute force computational solution

```
from math import sqrt
for p in range(1, 1000):
= (5*p**2 + 5*p)/4
t if sqrt(t).is_integer():
print("N = ", int(2*t))
```