[go: up one dir, main page]

login
A342704
Characteristic function of base-2 lunar primes: a(n) = 1 if n is a base-2 lunar prime, otherwise 0.
1
0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1
OFFSET
1
EXAMPLE
a(9) = 1 because 9 does not occur anywhere in the inner portion of the OR-numbral multiplication table A067138 (apart from its row/column 1). On the other hand, a(7) = 0 because A067138(3,3) = 7. - Antti Karttunen, Mar 21 2021
PROG
(Python)
def addn(m1, m2):
s1, s2 = bin(m1)[2:].zfill(0), bin(m2)[2:].zfill(0)
len_max = max(len(s1), len(s2))
return int(''.join(max(i, j) for i, j in zip(s1.rjust(len_max, '0'), s2.rjust(len_max, '0'))))
def muln(m1, m2):
s1, s2, prod = bin(m1)[2:].zfill(0), bin(m2)[2:].zfill(0), '0'
for i in range(len(s2)):
k = s2[-i-1]; prod = addn(int(str(prod), 2), int(''.join(min(j, k) for j in s1), 2)*2**i)
return prod
m = 1; m_size = 7; L_im = [1]
while m <= 2**m_size:
for i in range(2, m + 1):
im_st = str(muln(i, m)); im = int(im_st, 2); im_len = len(im_st)
if im_len > m_size: break
if im not in L_im: L_im.append(im)
print(1) if m not in L_im else print(0); m += 1
CROSSREFS
Characteristic function of A067139.
Cf. A342678 (partial sums), A067138, A169912, A171000, A171750, A171752.
Cf. also A010051, A091225.
Sequence in context: A209229 A365089 A295890 * A284622 A379184 A215581
KEYWORD
nonn,base
AUTHOR
Ya-Ping Lu, Mar 19 2021
STATUS
approved