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.

A178165 Number of unordered collections of distinct nonempty subsets of an n-element set where each element appears in at most 2 subsets.

Original entry on oeis.org

1, 2, 8, 59, 652, 9736, 186478, 4421018, 126317785, 4260664251, 166884941780, 7489637988545, 380861594219460, 21739310882945458, 1381634777325000263, 97089956842985393297, 7497783115765911443879, 632884743974716421132084
Offset: 0

Views

Author

Daniel E. Loeb, Dec 16 2010

Keywords

Comments

If each element must appear in exactly 1 subset, then we get the Bell numbers A000110.
If each element must appear in exactly 2 subsets, then we get A002718.

Crossrefs

Programs

  • Mathematica
    terms = m = 30;
    a094577[n_] := Sum[Binomial[n, k]*BellB[2n-k], {k, 0, n}];
    egf = Exp[(1 - Exp[x])/2]*Sum[a094577[n]*(x/2)^n/n!, {n, 0, m}] + O[x]^m;
    A094574 = CoefficientList[egf + O[x]^m, x]*Range[0, m-1]!;
    a[n_] := Sum[Binomial[n, k]*A094574[[k+1]], {k, 0, n}];
    Table[a[n], {n, 0, m-1}] (* Jean-François Alcover, May 24 2019 *)
  • Python
    from numpy import array
    def toBinary(n, k):
        ans=[]
        for i in range(k):
            ans.insert(0, n%2)
            n=n>>1
        return array(ans)
    def powerSet(k): return [toBinary(n,k) for n in range(1,2**k)]
    def courcelle(maxUses, remainingSets, exact=False):
        if exact and not all(maxUses<=sum(remainingSets)): ans=0
        elif len(remainingSets)==0: ans=1
        else:
            set0=remainingSets[0]
            if all(set0<=maxUses): ans=courcelle(maxUses-set0,remainingSets[1:],exact=exact)
            else: ans=0
            ans+=courcelle(maxUses,remainingSets[1:],exact=exact)
        return ans
    for i in range(10):
        print(i, courcelle(array([2]*i),powerSet(i),exact=False))

Formula

Binomial transform of A094574: a(n) = Sum_{k=0..n} C(n,k)*A094574(k).

Extensions

Edited and corrected by Max Alekseyev, Dec 19 2010