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.

A372318 For any n > 0, reverse digits in blocks in balanced ternary expansion of n where blocks are separated by 1's; a(0) = 0.

This page as a plain text file.
%I A372318 #10 Apr 30 2024 14:48:59
%S A372318 0,1,2,3,4,5,8,7,6,9,10,11,12,13,14,23,16,17,26,25,20,21,22,15,24,19,
%T A372318 18,27,28,29,30,31,32,35,34,33,36,37,38,39,40,41,68,43,50,77,70,47,48,
%U A372318 49,44,71,52,53,80,79,74,75,76,59,62,61,60,63,64,65,66,67
%N A372318 For any n > 0, reverse digits in blocks in balanced ternary expansion of n where blocks are separated by 1's; a(0) = 0.
%C A372318 This sequence is a self-inverse permutation of the nonnegative integers.
%C A372318 This sequence has infinitely many fixed points (A005836, among others).
%H A372318 Rémy Sigrist, <a href="/A372318/b372318.txt">Table of n, a(n) for n = 0..6561</a>
%H A372318 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A372318 For n = 1562: the balanced ternary expansion of 1562 is "1T0110TT" (where T denotes -1), we have three blocks: "T0", "" and "0TT", their reversals are: "0T", "" and "TT0", so the balanced ternary expansion of a(1562) is "10T11TT0", and a(1562) = 2040.
%o A372318 (PARI) a(n) = { my (d = [], i = 1); while (n, d = concat(centerlift(Mod(n, 3)), d); n = (n - d[1])/3;); for (j = 2, #d+1, if (j==#d+1 || d[i]==d[j], my (ii = i+1, jj = j-1); while (ii < jj, [d[ii], d[jj]] = [d[jj], d[ii]]; ii++; jj--;); i = j;);); fromdigits(d, 3); }
%Y A372318 See A372317 for a similar sequence.
%Y A372318 Cf. A005836.
%K A372318 nonn,base
%O A372318 0,3
%A A372318 _Rémy Sigrist_, Apr 27 2024