# Python program for OEIS A237500 # by Michael S. Branicky, Feb 06 2021 from numba import njit @njit def a(n): fullmask = (1<<(2*n)) - 1 lasthalfmask = (1<> n complement2 = complement & lasthalfmask comp1_is_in = False for j in range(n+1): shiftedmask = lasthalfmask << j if ((shiftedmask & k) >> j) ^ complement1 == 0: comp1_is_in = True break if not comp1_is_in: continue comp2_is_in = False for j in range(n+1): shiftedmask = lasthalfmask << j if ((shiftedmask & k) >> j) ^ complement2 == 0: comp2_is_in = True break if not comp2_is_in: continue c += 1 return 2*c from time import time time0 = time() for n in range(1, 101): an = a(n) print(n, an, time()-time0, flush=True)