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.

A278348 Number of 2 X 2 singular integer matrices with elements from {0,...,n} with no elements repeated.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 16, 16, 32, 40, 72, 72, 136, 136, 184, 248, 304, 304, 408, 408, 536, 632, 712, 712, 920, 968, 1064, 1168, 1360, 1360, 1664, 1664, 1848, 2008, 2136, 2328, 2696, 2696, 2840, 3032, 3432, 3432, 3880, 3880, 4200, 4592, 4768, 4768, 5336, 5456, 5824
Offset: 0

Views

Author

Indranil Ghosh, Nov 18 2016

Keywords

Comments

If p is prime then a(p) = a(p-1). - Robert G. Wilson v, Nov 20 2016

Crossrefs

Cf. A059306 (where in the matrices each element can be present multiple times).

Programs

  • C
    See Greathouse link.
  • Mathematica
    f[n_] := f[n] = Block[{a = 1, b, c, s = 0}, While[b = a + 1; a < n + 1, While[c = b + 1; b < n + 1, While[c < n + 1, If[a != b && a != c && a != n && b != c && b != n && c != n && a*n == b*c, s++]; c++]; b++]; a++]; 8 s + f[n - 1]]; f[0] = 0; Array[f, 51] (* or *)
    g[n_] := g[n] = Block[{c = 0, k = 1}, While[k < n, c += Count[ Times @@@ Select[ Tuples[ Rest@ Most@ Divisors[k*n], 2], #[[1]] < #[[2]] < n &], k*n]; k++]; c]; 8*Accumulate[ Array[g, 51]] (* much faster but both are recursive *) (* Robert G. Wilson v, Nov 20 2016 *)
  • PARI
    try(a,b,c,n)=my(d=b*c/a); denominator(d)==1 && d<=n && d!=a && d!=b && d!=c
    a(n)=2*sum(a=3,n, sum(b=2,a-1, sum(c=1,b-1, try(a,b,c,n) + try(c,a,b,n) + try(b,a,c,n)))) \\ Charles R Greathouse IV, Nov 20 2016
    
  • Python
    def p(n):
        s=0
        for a in range(n+1):
            for b in range(n+1):
                for c in range(n+1):
                    for d in range(n+1):
                        if (a!=b  and a!=d and b!=d and c!=a and c!=b and c!=d):
                            if a*d==b*c:
                                s+=1
        return s
    for i in range(101):
        print(str(i)+" "+str(p(i)))