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 A257004 #15 Jun 07 2025 08:14:47 %S A257004 1,2,3,3,5,4,4,6,7,5,5,10,7,10,11,9,6,8,10,7,10,16,12,11,16,8,10,12, %T A257004 21,17,8,10,14,14,18,21,13,12,14,27,11,16,26,15,17,18,23,16,10,20,25, %U A257004 11,13,32,14,18,26,27,18,18,38,24,15,18,28 %N A257004 Number of primitive Zagier-reduced indefinite quadratic forms over the integers in two variables with discriminants D(n) = A079896(n). %C A257004 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 A257004 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 A257004 A form is primitive if its coefficients are relatively prime. %D A257004 D. B. Zagier, Zetafunktionen und quadratische Körper, Springer, 1981. See page 122. %H A257004 Robin Visser, <a href="/A257004/b257004.txt">Table of n, a(n) for n = 1..10000</a> %e A257004 For D=20, the a(6)=4 Zagier-reduced primitive forms are x^2+6*x*y+4*y^2, 4*x^2+6*x*y+y^2, 4*x^2+10*x*y+5*y^2, and 5*x^2+10*x*y+4*y^2. %t A257004 Table[Length[ %t A257004 Select[Flatten[ %t A257004 Select[ %t A257004 Table[{a, k}, {k, %t A257004 Select[Range[Ceiling[-Sqrt[n]], Floor[Sqrt[n]]], %t A257004 Mod[# - n, 2] == 0 &]}, {a, %t A257004 Select[Divisors[(n - k^2)/4], # > (Sqrt[n] - k)/2 &]}], %t A257004 UnsameQ[#, {}] &], 1], %t A257004 GCD[#[[1]], #[[2]] + %t A257004 2*#[[1]], #[[1]] + #[[2]] - (n - #[[2]]^2)/(4*#[[1]])] == 1 &]], {n, %t A257004 Select[Range[ %t A257004 153], ! IntegerQ[Sqrt[#]] && (Mod[#, 4] == 0 || Mod[#, 4] == 1) &]}] %o A257004 (SageMath) %o A257004 def a(n): %o A257004 i, D, ans = 1, Integer(5), 0 %o A257004 while(i < n): %o A257004 D += 1; i += 1*(((D%4) in [0, 1]) and (not D.is_square())) %o A257004 for k in range(-isqrt(D), isqrt(D)+1): %o A257004 if ((D-k^2)%4 != 0): continue %o A257004 for h in Integer((D-k^2)/4).divisors(): %o A257004 if gcd([h, k+2*h, (k+h-(D-k^2)/(4*h))])==1: %o A257004 if h > (sqrt(D)-k)/2: ans += 1 %o A257004 return ans # _Robin Visser_, Jun 01 2025 %Y A257004 Cf. A079896, A082174, A257003. %K A257004 nonn %O A257004 1,2 %A A257004 _Barry R. Smith_, Apr 17 2015 %E A257004 Offset corrected by _Robin Visser_, Jun 01 2025