Alexander Bogomolny (@CutTheKnotMath) has a nice post “A Farewell Problem for the Year 2017” on his website Cut The Knot.

The problem is to find the least positive integer for which is a perfect square.

The proof on the Cut The Knot webpage shows also shows that there is, in fact, only one such .

A key part of the proof is that 2017 is a prime number.

What would happen if 2017 were replaced by an arbitrary prime number ?

Could we still prove that there is exactly one positive integer for which is a perfect square?

Well, no, because can never be a perfect square: if for some integer then which is not an integer when is an integer.

We can see that the primes 3 and 5 are OK because is a perfect square, as is .

On the assumption that for all odd primes we can find a positive integer for which is a perfect square, we can write a Mathematica code snippet to find the least such given the prime:

**primefunc[k0_] := Module[{k = k0, n}, n = 1; While[IntegerQ[Sqrt[n*(n + Prime[k])]] == False, n++]; n]**

This tells us what works for and

**primefunc[2]**

1

**primefunc[3]**

4

So, assuming the Mathematica code halts for odd primes we can create a table of pairs

(primes p, least n such that n(n+p) is a perfect square):

**T = Table[{Prime[n], primefunc[n]}, {n, 2, 100}]**

**ListPlot[T]**

{{3,1},{5,4},{7,9},{11,25},{13,36},{17,64},{19,81},{23,121},{29,196},{31,225},{37,324},{41,400},{43,441},{47,529},{53,676},{59,841},{61,900},{67,1089},{71,1225},{73,1296},{79,1521},{83,1681},{89,1936},{97,2304},{101,2500},{103,2601},{107,2809},{109,2916},{113,3136},{127,3969},{131,4225},{137,4624},{139,4761},{149,5476},{151,5625},{157,6084},{163,6561},{167,6889},{173,7396},{179,7921},{181,8100},{191,9025},{193,9216},{197,9604},{199,9801},{211,11025},{223,12321},{227,12769},{229,12996},{233,13456},{239,14161},{241,14400},{251,15625},{257,16384},{263,17161},{269,17956},{271,18225},{277,19044},{281,19600},{283,19881},{293,21316},{307,23409},{311,24025},{313,24336},{317,24964},{331,27225},{337,28224},{347,29929},{349,30276},{353,30976},{359,32041},{367,33489},{373,34596},{379,35721},{383,36481},{389,37636},{397,39204},{401,40000},{409,41616},{419,43681},{421,44100},{431,46225},{433,46656},{439,47961},{443,48841},{449,50176},{457,51984},{461,52900},{463,53361},{467,54289},{479,57121},{487,59049},{491,60025},{499,62001},{503,63001},{509,64516},{521,67600},{523,68121},{541,72900}}

We can notice fairly readily, that the values for we got, for a given odd prime , are themselves all perfect squares, and, in fact, .

Could this be correct for all odd primes ?

Sure!

The first thing to notice is that if is odd then is a positive integer and is a perfect square.

This bit doesn’t depend on being prime.

That this is the *only* positive integer for which is a perfect square, does rely on being prime and odd.

In fact, we can simply modify the argument at the post “A Farewell Problem for the Year 2017“:

if is a perfect square and is not a perfect square, then has a factor that is shared with and, hence, with . But is prime so the only possibility is , implying which can not be a perfect square unless .

So both and are perfect squares, say . From this we have , which is prime, so which means .

In other words, if is an odd prime then is the unique positive integer for which is a perfect square.