This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A274601 #45 Jan 28 2025 00:49:04 %S A274601 1,4,3,2,13,12,11,10,9,8,7,6,5,40,39,38,37,36,35,34,33,32,31,30,29,28, %T A274601 27,26,25,24,23,22,21,20,19,18,17,16,15,14,121,120,119,118,117,116, %U A274601 115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100 %N A274601 a(n) = 2*3^(s-1) - n, where s is the number of trits of n in balanced ternary form. %C A274601 Analogous to a bit, a ternary digit is a trit. %C A274601 Per the definition, n + a(n) = 2*3^(s-1), where s is the number of trits of n and a(n), n and a(n) form a decomposition of 2*3^(s-1). %H A274601 Lei Zhou, <a href="/A274601/b274601.txt">Table of n, a(n) for n = 1..10000</a> %F A274601 a(n) = 2*3^(floor(log_3(2*n-1))) - n. [corrected by _Jason Yuen_, Nov 18 2024] %e A274601 For n=1 the balanced ternary form of 1 is 1, which has 1 trits. 2*3^(1-1)-1 = 1, so a(1) = 1. %e A274601 For n=2 the balanced ternary form of 2 is 1T, which has 2 trits. 2*3^(2-1)-2 = 4, so a(2) = 4. %e A274601 For n=3 the balanced ternary form of 3 is 10, which has 2 trits. 2*3^(2-1)-3 = 3, so a(2) = 3. %e A274601 ... %e A274601 For n=62 the balanced ternary form of 62 is 1T10T, which has 5 trits. 2*3^(5-1)-62 = 100, so a(62) = 100. %t A274601 Table[2*3^(Floor[Log[3, 2*n - 1]]) - n, {n, 1, 62}] %o A274601 (Python) %o A274601 from sympy import integer_log %o A274601 def a(n): return 2*3**(integer_log(2*n - 1, 3)[0]) - n %o A274601 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 10 2017 %o A274601 (PARI) a(n) = 2*3^logint(2*n-1,3)-n \\ _Jason Yuen_, Nov 18 2024 %Y A274601 Cf. A117966, A134021, A140267, A134028. %K A274601 nonn,base,easy %O A274601 1,2 %A A274601 _Lei Zhou_, Nov 10 2016