A330407 Number of ordered integer pairs (b,c) with -n <= b <= n and -n <= c <= n such that both roots of x^2 + b*x + c = 0 are distinct integers.
0, 3, 7, 13, 20, 26, 36, 42, 52, 59, 69, 75, 89, 95, 105, 115, 126, 132, 146, 152, 166, 176, 186, 192, 210, 217, 227, 237, 251, 257, 275, 281, 295, 305, 315, 325, 344, 350, 360, 370, 388, 394, 412, 418, 432, 446, 456, 462, 484, 491, 505, 515, 529, 535, 553, 563, 581
Offset: 0
Keywords
Examples
For n = 1, the a(1) = 3 equations are x^2 - x = 0, x^2 + x = 0, and x^2 - 1 = 0. For n = 2, the a(2) = 7 equations are the 3 equations listed above and x^2 - 2x = 0, x^2 + 2x = 0, x^2 - x - 2 = 0, and x^2 + x - 2 = 0.
Programs
-
Mathematica
ok[b_, c_] := Block[{d = b^2 - 4 c}, d > 0 && IntegerQ@ Sqrt@ d]; a[n_] := Sum[ Boole@ ok[b, c], {b, -n, n}, {c, -n, n}]; Array[a, 57, 0] (* Giovanni Resta, Jan 28 2020 *)
-
PARI
isok(b,c) = (b^2 > 4*c) && issquare(b^2-4*c); a(n) = sum(b=-n, n, sum(c=-n, n, isok(b,c))); \\ Michel Marcus, Jan 28 2020
Extensions
a(0)=0 prepended by Michel Marcus, Jan 30 2020