OFFSET
3,2
COMMENTS
See A257009 for the definition of the alternant of a sequence. The number of sequences of length 1 with given alternant value n is 1, while the number of sequences of length 2 with given alternant value n is d(n), the number of divisors of n (see A000005).
There are infinitely many sequences of length 3 and alternant equal to 2. It is for this reason that the offset is 3.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 3..1000
B. R. Smith, Reducing quadratic forms by kneading sequences J. Int. Seq., 17 (2014) 14.11.8.
FORMULA
a(n) = Sum_{b=1..n-1} (Dbm (b,b^2+nb+1)-2), where Dbm(b,m) is the number of positive divisors of m that are congruent to 1 modulo b. - Barry R. Smith, Jan 24 2016
EXAMPLE
For n=6, the a(6) = 4 sequences with alternant 6 are (1,1,3), (1,3,2), (2,3,1), (3,1,1)
MAPLE
Dbm:= proc(b, m) nops(select(t -> (t-1) mod b = 0, numtheory:-divisors(m))) end proc:
seq(add(Dbm(b, b^2+n*b+1)-2, b=1..n-1), n=3..100); # Robert Israel, Jan 24 2016
MATHEMATICA
Length3Q[x_, y_] :=
Module[{l = ContinuedFraction[(x[[2]] + 2*x[[1]] + y)/(2*x[[1]])]},
If[OddQ[Length[l]], Return[Length[l] == 3],
If[Last[l] == 1, Return[Length[l] - 1 == 3], Return[Length[l] + 1 == 3]]]];
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], Length3Q[#, n] &]], {n, 3, 60}]
PROG
(PARI) a(n)={sum(b=1, n-1, sumdiv(b^2+n*b+1, d, (d-1)%b==0) - 2)} \\ Andrew Howroyd, May 01 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Barry R. Smith, Apr 18 2015
EXTENSIONS
Terms a(61) and beyond from Andrew Howroyd, May 01 2020
STATUS
approved