x - the prime
y² - the first perfect square
(y + 1)² - the second perfect square
(1) x = y² + 4
(2) x = (y + 1)² - 7
subtitute (2) to (1)
(y + 1)² - 7 = y² + 4 |use (a + b)² = a² + 2ab + b²
y² + 2y + 1 - 7 = y² + 4 |subtract y² from both sides
2y - 6 = 4 |add 6 to both sides
2y = 10 |divide both sides by 2
y = 5
subtitute the value of y to (1)
x = 5² + 4 = 25 + 4 = 29
check:
29 - it's prime /correct/
29 - 4 = 25 = 5² - the perfect square /correct/
29 + 7= 36 = 6² - the next-largest perfect square /correct/
Answer: 29.