## Pentagonal numbers are generated by the formula, $P_n=n(3n-1)/2$. The first ten pentagonal numbers are:

$$1, 5, 12, 22, 35, 51, 70, 92, 117, 145, \dots$$

It can be seen that $P_4 + P_7 = 22 + 70 = 92 = P_8$. However, their difference, $70 – 22 = 48$, is not pentagonal.

Find the pair of pentagonal numbers, $P_j$ and $P_k$, for which their sum and difference are pentagonal and $D = |P_k – P_j|$ is minimised; what is the value of $D$?

### To solve this problem, we can iterate through pentagonal numbers and check for the conditions mentioned:

- Find pentagonal numbers $P_j$ and $P_k$ where their sum and difference are pentagonal.
- Calculate the absolute difference $D = |P_k – P_j|$ for each pair of pentagonal numbers.
- Keep track of the minimum value of $D$ and the corresponding pair of pentagonal numbers.

Here’s the Python code to accomplish this:

def is_pentagonal(n):

# Check if a number is pentagonal using the inverse formula

x = (1 + (1 + 24 * n) ** 0.5) / 6

return x.is_integer()

def find_minimal_D():

min_D = float(‘inf’)

min_D_pair = None

for k in range(2, 10000):

P_k = k * (3 * k – 1) // 2

for j in range(k – 1, 0, -1):

P_j = j * (3 * j – 1) // 2

if is_pentagonal(P_k – P_j) and is_pentagonal(P_k + P_j):

D = abs(P_k – P_j)

if D < min_D:

min_D = D

min_D_pair = (P_j, P_k)

return min_D, min_D_pair

minimal_D, minimal_D_pair = find_minimal_D()

print(“Minimal D:”, minimal_D)

print(“Pentagonal pair:”, minimal_D_pair)

When you run this code, it will output the minimal value of $D$ and the corresponding pair of pentagonal numbers $P_j$ and $P_k$ that satisfy the conditions.

##### More Answers:

Pandigital PrimeCoded Triangle Numbers

Sub-string Divisibility