This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A257003 #37 Jun 02 2025 06:47:09 %S A257003 1,2,3,3,5,5,4,6,7,5,7,10,7,10,11,9,7,11,13,7,10,16,12,11,16,13,10,14, %T A257003 21,17,8,15,18,14,18,21,13,12,20,27,11,16,26,18,17,25,23,21,13,20,25, %U A257003 12,20,32,24,18,26,27,18,18,38,31,15,18,33 %N A257003 Number of Zagier-reduced indefinite quadratic forms over the integers in two variables with discriminants D(n) = A079896(n). %C A257003 An indefinite quadratic form in two variables over the integers, A*x^2 + B*x*y + C*y^2 with discriminant D = B^2 - 4*A*C > 0, 0 or 1 (mod 4) and not a square, is called Zagier-reduced if A>0, C>0, and B>A+C. %C A257003 This definition is from Zagier's 1981 book, and differs from the older and more common notion of reduced form due to Lagrange (see A082175 for this definition). %C A257003 The number of pairs of integers (h,k) with |k| < sqrt(D), k^2 congruent to D (mod 4), h > (sqrt(D) - k)/2, h exactly dividing (D-k^2)/4, where D=D(n) is the discriminant being considered. %D A257003 D. B. Zagier, Zetafunktionen und quadratische Körper, Springer, 1981. See pages 122-123. %H A257003 Robin Visser, <a href="/A257003/b257003.txt">Table of n, a(n) for n = 1..10000</a> (terms n = 1..1000 from Barry R. Smith). %F A257003 a(n) equals the number of pairs (h,k) with |k| < sqrt(D), k^2 congruent to D (mod 4), h > (sqrt(D) - k)/2, h exactly dividing (D-k^2)/4, where D=D(n) is the discriminant being considered. %e A257003 For D=20, the pairs (h,k) as above are: (1,4), (2,2), (4,2), (5,0), (4,-2). From these, the a(6)=5 Zagier-reduced forms may be enumerated as h*x^2 + (k+2*h)*x*y + (k+h-(D-k^2)/(4*h))*y^2, yielding x^2+6*x*y+4*y^2, 2*x^2+6*x*y+2*y^2, 4*x^2+10*x*y+5*y^2, 5*x^2+10*x*y+4*y^2, and 4*x^2+6*x*y+y^2. %t A257003 Table[Length[ %t A257003 Flatten[Select[ %t A257003 Table[{a, k}, {k, %t A257003 Select[Range[Ceiling[-Sqrt[n]], Floor[Sqrt[n]]], %t A257003 Mod[# - n, 2] == 0 &]}, {a, %t A257003 Select[Divisors[(n - k^2)/4], # > (Sqrt[n] - k)/2 &]}], %t A257003 UnsameQ[#, {}] &], 1]], {n, %t A257003 Select[Range[ %t A257003 153], ! IntegerQ[Sqrt[#]] && (Mod[#, 4] == 0 || %t A257003 Mod[#, 4] == 1) &]}] %o A257003 (SageMath) %o A257003 def a(n): %o A257003 i, D, ans = 1, Integer(5), 0 %o A257003 while(i < n): %o A257003 D += 1; i += 1*(((D%4) in [0, 1]) and (not D.is_square())) %o A257003 for k in range(-isqrt(D), isqrt(D)+1): %o A257003 if ((D-k^2)%4 != 0): continue %o A257003 for h in Integer((D-k^2)/4).divisors(): %o A257003 if h > (sqrt(D) - k)/2: ans += 1 %o A257003 return ans # _Robin Visser_, Jun 01 2025 %Y A257003 Cf. A079896, A082175, A257004. %K A257003 nonn %O A257003 1,2 %A A257003 _Barry R. Smith_, Apr 14 2015 %E A257003 Offset corrected by _Robin Visser_, Jun 01 2025