login
Number of unimodular 2 X 2 matrices having entries in {0,1,...,n} with no entry repeated.
2

%I #38 Jun 11 2024 23:46:16

%S 0,0,0,0,0,8,8,40,48,80,88,152,160,232,264,304,344,448,480,608,648,

%T 720,784,944,968,1104,1176,1304,1376,1576,1616,1840,1944,2080,2184,

%U 2352,2424,2688,2816,2984,3072,3368,3440,3760,3896,4064,4224,4576,4664,4984,5120

%N Number of unimodular 2 X 2 matrices having entries in {0,1,...,n} with no entry repeated.

%C a(n) mod 8 = 0.

%H Robert Israel, <a href="/A278846/b278846.txt">Table of n, a(n) for n = 0..1000</a> (terms 0..241 from Indranil Ghosh)

%p df:= proc(n) local count, c,d,q,av,bc,a,b;

%p count:= 0:

%p for d from 1 to n-1 do

%p av:= {$1..n-1} minus {d};

%p for q in [-1,1] do

%p bc:= n*d+q;

%p for b in numtheory:-divisors(bc) intersect av do

%p c:= bc/b;

%p if c < b and member(c,av) then count:=count+8 fi;

%p od od od;

%p count

%p end proc:

%p ListTools:-PartialSums(map(df, [$0..100])); # _Robert Israel_, Nov 29 2016

%t df[n_] := Module[{count = 0, c, d, q, av, bc, a, b}, Do[av = Range[n - 1] ~Complement~ {d}; Do[bc = n d + q; Do[c = bc/b; If[c < b && MemberQ[av, c], count += 8], {b, Divisors[bc] ~Intersection~ av}], {q, {-1 , 1}}], {d, 1, n - 1}]; count];

%t df /@ Range[0, 100] // Accumulate (* _Jean-François Alcover_, Jul 29 2020, after _Robert Israel_ *)

%o (Python)

%o def a(n):

%o s=0

%o for a in range(0,n+1):

%o for b in range(0,n+1):

%o for c in range(0,n+1):

%o for d in range(0,n+1):

%o if (a!=b and a!=d and b!=d and c!=a and c!=b and c!=d):

%o if abs(a*d-b*c)==1:

%o s+=1

%o return s

%o print([a(n) for n in range(0, 52)]) # _Indranil Ghosh_, Nov 29 2016

%Y Cf. A210000 (where the matrix entries can be repeated).

%K nonn

%O 0,6

%A _Indranil Ghosh_, Nov 29 2016