cp's OEIS Frontend

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.

A352502 a(n) is the number of integers k in the interval 0..n such that k and n-k can be added without carries in balanced ternary.

This page as a plain text file.
%I A352502 #108 May 01 2022 11:42:48
%S A352502 1,2,2,4,4,2,4,4,6,10,8,6,10,8,2,4,4,6,10,8,6,10,8,10,16,12,18,28,20,
%T A352502 14,22,16,10,16,12,18,28,20,14,22,16,2,4,4,6,10,8,6,10,8,10,16,12,18,
%U A352502 28,20,14,22,16,10,16,12,18,28,20,14,22,16,18,28,20,30
%N A352502 a(n) is the number of integers k in the interval 0..n such that k and n-k can be added without carries in balanced ternary.
%C A352502 Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position.
%C A352502 This sequence has connections with Gould's sequence (A001316); here we work with balanced ternary, there with binary.
%H A352502 Rémy Sigrist, <a href="/A352502/b352502.txt">Table of n, a(n) for n = 0..6561</a>
%H A352502 Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>
%F A352502 a(n) <= n+1 with equality iff n belongs to A140429.
%F A352502 a(3*n) = 3*a(n) - 2.
%F A352502 a(3*n+1) = a(3*n-1) + 2.
%e A352502 For n = 8:
%e A352502 - we consider the following cases:
%e A352502               k|    0    1    2    3    4    5    6    7    8
%e A352502       ---------+---------------------------------------------
%e A352502         bter(k)|    0    1   1T   10   11  1TT  1T0  1T1  10T
%e A352502       bter(8-k)|  10T  1T1  1T0  1TT   11   10   1T    1    0
%e A352502        carries?|  no   yes  no   no   yes  no   no   yes  no
%e A352502 - so a(8) = 6.
%o A352502 (PARI) ok(u,v) = { while (u && v, my (uu=[0,+1,-1][1+u%3], vv=[0,+1,-1][1+v%3]); if (abs(uu+vv)>1, return (0)); u=(u-uu)/3; v=(v-vv)/3); return (1) }
%o A352502 a(n) = sum(k=0, n, ok(n-k, k))
%Y A352502 Cf. A001316, A059095, A140429, A353174 (corresponding k's).
%K A352502 nonn,base
%O A352502 0,2
%A A352502 _Rémy Sigrist_, Apr 28 2022