%I M4254 #29 Oct 31 2023 04:45:23
%S 0,6,48,168,480,966,2016,3360,5616,8550,13200,17832,26208,34566,45840,
%T 59520,78336,95526,123120,147240,181776,219846,267168,307488,372000,
%U 433446,505440,580776,682080,762150,892800,999936,1138368,1284486
%N Number of 2 X 2 matrices with entries mod n and nonzero determinant.
%D T. Brenner, personal communication.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H T. D. Noe, <a href="/A005353/b005353.txt">Table of n, a(n) for n=1..1000</a>
%H Richard K. Guy, <a href="/A005353/a005353.pdf">Letter to N. J. A. Sloane, Sep 1989</a>.
%F a(n) = n^4 - A020478(n).
%F For prime n, a(n) = (n^2-1)(n-1)n. - _T. D. Noe_, Jan 12 2006
%t Table[cnt=0; Do[m={{a, b}, {c, d}}; If[Det[m, Modulus->p] > 0, cnt++ ], {a, 0, p-1}, {b, 0, p-1}, {c, 0, p-1}, {d, 0, p-1}]; cnt, {p, 37}] (* _T. D. Noe_, Jan 12 2006 *)
%t f[p_, e_] := p^(2*e - 1)*(p^(e + 1) + p^e - 1); a[1] = 0; a[n_] := n^4 - Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* _Amiram Eldar_, Oct 31 2023 *)
%o (PARI) a(n) = {my(f = factor(n), p, e); n^4 - prod(i = 1, #f~, p = f[i, 1]; e = f[i, 2]; p^(2*e - 1)*(p^(e + 1) + p^e - 1));} \\ _Amiram Eldar_, Oct 31 2023
%Y Cf. A020478, A059306, A062801.
%K nonn,easy,nice
%O 1,2
%A _N. J. A. Sloane_, _R. K. Guy_
%E More terms from _T. D. Noe_, Jan 12 2006