cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

0, 0, 0, 0, 0, 8, 8, 40, 48, 80, 88, 152, 160, 232, 264, 304, 344, 448, 480, 608, 648, 720, 784, 944, 968, 1104, 1176, 1304, 1376, 1576, 1616, 1840, 1944, 2080, 2184, 2352, 2424, 2688, 2816, 2984, 3072, 3368, 3440, 3760, 3896, 4064, 4224, 4576, 4664, 4984, 5120
Offset: 0

Views

Author

Indranil Ghosh, Nov 29 2016

Keywords

Comments

a(n) mod 8 = 0.

Crossrefs

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

Programs

  • Maple
    df:= proc(n) local count, c,d,q,av,bc,a,b;
      count:= 0:
      for d from 1 to n-1 do
          av:= {$1..n-1} minus {d};
          for q in [-1,1] do
            bc:= n*d+q;
            for b in numtheory:-divisors(bc) intersect av do
              c:= bc/b;
              if c < b and member(c,av) then count:=count+8 fi;
      od od od;
      count
    end proc:
    ListTools:-PartialSums(map(df, [$0..100])); # Robert Israel, Nov 29 2016
  • Mathematica
    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];
    df /@ Range[0, 100] // Accumulate (* Jean-François Alcover, Jul 29 2020, after Robert Israel *)
  • Python
    def a(n):
        s=0
        for a in range(0,n+1):
            for b in range(0,n+1):
                for c in range(0,n+1):
                    for d in range(0,n+1):
                        if (a!=b  and a!=d and b!=d and c!=a and c!=b and c!=d):
                            if abs(a*d-b*c)==1:
                                s+=1
        return s
    print([a(n) for n in range(0, 52)]) # Indranil Ghosh, Nov 29 2016