OFFSET
1,4
COMMENTS
LINKS
B. R. Smith, Reducing quadratic forms by kneading sequences J. Int. Seq., 17 (2014) 14.11.8.
EXAMPLE
The a(7) = 3 sequences with length 5 and alternant 7 are (1,1,1,3,1), (1,2,1,2,1), and (1,3,1,1,1).
MATHEMATICA
Length5Q[x_, y_] :=
Module[{l = ContinuedFraction[(x[[2]] + 2*x[[1]] + y)/(2*x[[1]])]},
If[OddQ[Length[l]], Return[Length[l] == 5],
If[Last[l] == 1, Return[Length[l] - 1 == 5], Return[Length[l] + 1 == 5]]]];
Table[Length[
Select[Flatten[
Select[
Table[{a, k}, {k,
Select[Range[Ceiling[-Sqrt[n^2 - 4]], Floor[Sqrt[n^2 - 4]]],
Mod[# - n^2 + 4, 2] == 0 &]}, {a,
Select[Divisors[(n^2 - 4 - k^2)/4], # > (Sqrt[n^2 - 4] - k)/2 &]}],
UnsameQ[#, {}] &], 1], Length5Q[#, n] &]], {n, 3, 80}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Barry R. Smith, Apr 19 2015
STATUS
approved