OFFSET
1,2
COMMENTS
For n>1, n + a(n) is composite and n + a(n) is square if and only if n is square. - David A. Corneth, Oct 22 2016
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, B30.
LINKS
Peter Kagey, Table of n, a(n) for n = 1..10000
H. B. Bui, K. Pratt, and A. Zaharescu, A problem of Erdos-Graham-Granville-Selfridge on integral points on hyperelliptic curves, arXiv:2211.12467 [math.NT], 2022.
A. Granville and J. L. Selfridge, Products of integers in an interval, modulo squares, Electron. J. Combin. 8 (2001), no. 1.
FORMULA
a(n) = A006255(n) - n. - Peter Kagey, Oct 22 2016
a(n^2) = 0, a(p) = p for prime p > 3. - David A. Corneth, Oct 22 2016
EXAMPLE
a(48)=6 because 48*(48+2)*(48+6) is a square, but you can't square 48 with numbers from (48+1) to (48+5).
MATHEMATICA
Table[k = 0; Which[IntegerQ@ Sqrt@ n, k, And[PrimeQ@ n, n > 3], k = n, True, While[Length@ Select[n Map[Times @@ # &, n + Rest@ Subsets@ Range@ k], IntegerQ@ Sqrt@ # &] == 0, k++]]; k, {n, 40}] (* Michael De Vlieger, Oct 26 2016 *)
Table[k = 0; Which[IntegerQ@Sqrt@n, k, First@Last@FactorInteger@n > Sqrt[2 n] + 1, k = First@Last@FactorInteger@n, True, While[Length@Select[n Map[Times @@ # &, n + Rest@Subsets@Range@k], IntegerQ@Sqrt@# &] == 0, k++]]; k, {n, 100}] (* Joshua Stucky, December 5 2022 *)
PROG
(PARI) a(n) = {if(issquare(n), return(0)); if(isprime(n), if(n>3, return(n), return(n+2) )); my(l = List([n, n+1]), m=2); while(1, for(i=1, #l-2, forvec(v = vector(i, j, [2, #l-1]), if(issquare(l[1] * l[#l] * prod(k=1, #v, l[v[k]])), return(l[#l] - n)), 2)); listput(l, n+m); m++)} \\ David A. Corneth, Oct 22 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Don Reble, Apr 03 2004
STATUS
approved