OFFSET
0,2
COMMENTS
Write n in base 3, then (working from left to right) if the k-th digit of n is equal to the corresponding digit to the left of the k-th digit of a(n) then this is the k-th digit of a(n), otherwise the k-th digit of a(n) is the element of {0,1,2} which has not just been compared, then read result as a base 3 number.
LINKS
FORMULA
a(n) = 3*a(floor(n/3)) + ((-a(floor(n/3))-n) mod 3) = 3*a(floor(n/3)) + A060582(n) with a(0)=0.
EXAMPLE
a(46) = 76 since 43 = 1201_3; this gives a first digit of 2(=3-1-0), a second digit of 2(=2=2), a third digit of 1(=3-2-0) and a fourth digit of 1(=1=1); 2211_3 = 76.
CROSSREFS
KEYWORD
AUTHOR
Henry Bottomley, Apr 04 2001
STATUS
approved