OFFSET
2,2
COMMENTS
Motivated by the following original problem: the population of a city is a square number. With 100 more people, it would be a square plus one, with again 100 more people it would be a square. What is the initial population of the city? Answer: 2401. See Images des Mathématiques link.
One remarks that one can solve the problem when the population increase is even and greater than 1. So in the sequence definition, 2*n is the population increase and k^2 is the initial population.
One also notes that a(n) always exists with a(n) <= n-1.
LINKS
Michel Marcus, Table of n, a(n) for n = 2..1000
Ana Rechtman, Juin 1er défi, Images des Mathématiques, CNRS, 2019 (in French).
EXAMPLE
For n=2, that is a population increase of 4, the population is 1 (a square), since we have 1+4-1 = 4 (a square) and 1+8 = 9 (a square).
For n=28, that is a population increase of 56, the population is 9 (a square), since we have 9+56-1 = 64 (a square) and 9+112 = 121 (a square).
MATHEMATICA
okQ[m_, k_] := IntegerQ[Sqrt[m]] && IntegerQ[Sqrt[m+k-1]] && IntegerQ[ Sqrt[m+2k]];
findm[k_] := Module[{m = 1}, While[!okQ[m^2, k], m++]; m];
a[n_] := findm[2n];
Table[a[n], {n, 2, 72}] (* Jean-François Alcover, Jun 18 2019, from PARI *)
PROG
(PARI) isok(m, k) = issquare(m) && issquare(m+k-1) && issquare(m+2*k);
findm(k) = my(m=1); while (!isok(m^2, k), m++); m;
a(n) = findm(2*n);
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Marcus, Jun 18 2019
STATUS
approved