OFFSET
1,1
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..10000
MATHEMATICA
a[1] = 0; h = 50;
Table[a[3 k - 2] = a[k], {k, 1, h}];
Table[a[3 k - 1] = a[k], {k, 1, h}];
Table[a[3 k] = 1, {k, 1, h}];
Flatten[Position[%%, 1]]
PROG
(Python)
from gmpy2 import digits
def A189822(n):
def f(x):
l = (s:=digits(x-1, 3)).find('2')
if l >= 0: s = s[:l]+'1'*(len(s)-l)
return n+1+int(s, 2)
m, k = n, f(n)
while m != k: m, k = k, f(k)
return m # Chai Wah Wu, Dec 05 2024
CROSSREFS
KEYWORD
nonn,easy,changed
AUTHOR
Clark Kimberling, Apr 28 2011
STATUS
approved