%I #10 Apr 30 2021 01:07:44
%S 0,2,3,0,5,6,7,7,0,10,9,11,13,10,12,0,13,14,17,15,18,18,13,20,0,16,18,
%T 25,21,20,25,20,24,26,18,0,31,18,26,34,27,24,29,29,31,34,19,31,0,24,
%U 32,39,29,32,36,34,38,36,27,40,47,22,31,0,38,36,41,33,44
%N Number of stable modules [f, g + sqrt(n)] in canonical form.
%C Stable modules arise in Edwards's recasting of Gauss's theory of binary quadratic forms. See either Edwards reference for the definitions of stable modules and canonical form.
%D Harold M. Edwards, Essays in Constructive Mathematics, Springer, 2005, page 80 and pages 90-92.
%D Harold M. Edwards, Higher Arithmetic: An Algorithmic Introduction to Number Theory, American Mathematical Society, 2008, page 119 and pages 169-177.
%F a(n) = 0 when n is a square.
%e For n = 5 the a(5) = 5 stable modules are [1, sqrt(5)], [5, sqrt(5)], [2, 1 + sqrt(5)], [4, 1 + sqrt(5)], [4, 3 + sqrt(5)]. Applying Edwards' comparison algorithm to each stable module partitions them into two cycles: [1, sqrt(5)] -> [4, 3 + sqrt(5)] -> [5, sqrt(5)] -> [4, 1 + sqrt(5)] -> [1, sqrt(5)] and [2, 1 + sqrt(5)] -> [2, 1 + sqrt(5)].
%t Table[
%t Length[If[
%t IntegerQ[Sqrt[n]],
%t {},
%t Join @@ Table[
%t Join @@ Function[f,
%t If[k == 0 || 2 k == f,
%t {{f, k + Sqrt[n]}},
%t {{f, k + Sqrt[n]}, {f, f - k + Sqrt[n]}}
%t ]
%t ] /@ Select[Divisors[n - k^2], Function[f, f >= 2 k]],
%t {k, 0, Sqrt[n]}
%t ]
%t ]],
%t {n, 1, 100}
%t ]
%K nonn
%O 1,2
%A _Eric Rowland_, Dec 31 2018