# Python program for OEIS A347025 # Michael S. Branicky, Nov 06 2021 # Modified Nov 09 2021 from time import time time0 = time() from itertools import combinations from numba import njit @njit def allunions(sets): for k in range(1, 2**len(sets)): u, mask = 0, 1 for i in range(len(sets)): if mask & k: u |= sets[i] mask <<= 1 yield u def a(n): if n < 2: return n m = 2 while True: print("...", n, m, time()-time0) allfailed = True for family in combinations(range(1, 2**n), m): if len(set(family)) != m: continue unionfound = False for i in range(m): this = family[i] rest = family[:i] + family[i+1:] rest = [r for r in rest if r&this == r] if len(rest): allrest = 0 for r in rest: allrest |= r if allrest == this: unionfound = True break if unionfound: break allfailed &= unionfound if not unionfound: break if allfailed: return m - 1 m += 1 for n in range(0, 11): print(f"a{n} = {a(n)}\n")