OFFSET
1,1
LINKS
D. Applegate, M. LeBrun and N. J. A. Sloane, Dismal Arithmetic, arXiv:1107.1130 [math.NT], 2011. [Note: we have now changed the name from "dismal arithmetic" to "lunar arithmetic" - the old name was too depressing]
PROG
(Python)
def ternary(m):
if m == 0: return '0'
s = []
while m:
m, r = divmod(m, 3)
s.append(str(r))
return ''.join(reversed(s))
def addn(m1, m2):
s1, s2 = ternary(m1), ternary(m2)
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 = ternary(m1), ternary(m2), '0'
for i in range(len(s2)):
k = s2[-i-1]
prod = addn(int(str(prod), 3), int(''.join(min(j, k) for j in s1), 3)*3**i)
return prod
for m in range(3, 201):
i, ct = 1, 0
for i in range(1, m+1):
if i == 2: continue
j = i
for j in range(1, m+1):
if j == 2: continue
ij = int(str(muln(i, j)), 3)
if ij == m: ct += 1; break
if ct > 0: break
if ct == 0: print(m) # Ya-Ping Lu, Dec 30 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Sep 30 2010
EXTENSIONS
Entries >=83 from R. J. Mathar, Nov 23 2015
STATUS
approved