OFFSET
1,3
COMMENTS
We consider 2n-1 which has only odd divisors, so any difference among them is always even.
a(n) = 0 if and only if 2n - 1 is a square.
From Charles Kusniec, Oct 31 2024: (Start)
a(n) = 1 iff 2n is a square.
a(n) = 2 iff 2n-1 = (2k-1)^2 - 4.
a(n) = 3 iff 2n-1 = (2k)^2 - 9.
Since 2n-1 is odd, 2n-1 = d*D can be written 2n-1 = (x-y)*(x+y) = x^2 - y^2 with integers x and y, from which a(n) is the smallest possible y, which also means smallest possible x and that being x = A377499(n).
LINKS
Seiichi Manyama, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = sqrt(A377499(n)^2 - (2n-1)). - Charles Kusniec, Oct 31 2024
EXAMPLE
For n = 2, consider divisors of 2n - 1 = 3 which are {1, 3}. The least one greater than or equal to sqrt(3) is 3, the largest one less than or equal to sqrt(3) is 1; whence a(2) = (3 - 1)/2 = 1.
For n = 14, consider divisors of 2n - 1 = 27 which are {1, 3, 9, 27}. The least one greater than or equal to sqrt(27) is 9, the largest one less than or equal to sqrt(27) is 3; whence a(14) = (9 - 3)/2 = 3.
For n = 1, 5, 13, 25, ..., the number 2n - 1 equals the square 1, 9, 25, 49, ...; so the two beforementioned "median divisors" coincide with the square root, and a(n) = 0/2 = 0.
MATHEMATICA
Table[(Divisors[n][[(Length[Divisors[n]] - Boole[IntegerQ[Sqrt[n]]])/2 + 1]] - Divisors[n][[(Length[Divisors[n]] + Boole[IntegerQ[Sqrt[n]]])/2]])/2, {n, 1, 199, 2}] (* Alonso del Arte, Nov 25 2012, corrected March 21 2024, with help from Giorgos Kalogeropoulos *)
A219695[n_] := (d = Divisors[2n - 1]; l = Floor[Length@d/2 + 1]; (d[[l]] - d[[-l]])/2); Array[A219695, 100] (* Giorgos Kalogeropoulos, Mar 15 2024 *)
PROG
(PARI)
A056737(n)={n=divisors(n); n[(2+#n)\2]-n[(1+#n)\2]}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Nov 25 2012
STATUS
approved