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.

A338086 Duplicate the ternary digits of n, so each 0, 1 or 2 becomes 00, 11 or 22 respectively.

Original entry on oeis.org

0, 4, 8, 36, 40, 44, 72, 76, 80, 324, 328, 332, 360, 364, 368, 396, 400, 404, 648, 652, 656, 684, 688, 692, 720, 724, 728, 2916, 2920, 2924, 2952, 2956, 2960, 2988, 2992, 2996, 3240, 3244, 3248, 3276, 3280, 3284, 3312, 3316, 3320, 3564, 3568, 3572, 3600, 3604
Offset: 0

Views

Author

Kevin Ryde, Oct 09 2020

Keywords

Comments

Also, numbers whose ternary digit runs are all even lengths (including 0 reckoned as no digits at all). Also, change ternary digits 0,1,2 to base 9 digits 0,4,8, and hence numbers which can be written in base 9 using only digits 0,4,8.
Digit duplication 00,11,22 can be compared to A037314 which is 0 above each so 00,01,02, or A208665 which is 0 below each so 00,10,20. Duplication is the sum of these, or any one is a suitable multiple of another (*3, *4, etc).
This sequence is the points on the X=Y diagonal of the ternary Z-order curve (see example table in A163328). The Z-order curve takes a point number p and splits its ternary digits alternately to X and Y coordinates so X(p) = A163325(p) and Y(p) = A163326(p). Duplicate digits in a(n) are the diagonal X(a(n)) = Y(a(n)) = n.

Examples

			n=73 is ternary 2201 which duplicates to 22220011 ternary = 8804 base 9 = 6484 decimal.
		

Crossrefs

Cf. A020331 (ternary concatenation).
Digit duplication in other bases: A001196, A338754.

Programs

  • PARI
    a(n) = fromdigits(digits(n,3),9)<<2;
    
  • Python
    from gmpy2 import digits
    def A338086(n): return int(''.join(d*2 for d in digits(n,3)),3) # Chai Wah Wu, May 07 2022

Formula

a(n) = A037314(n) + A208665(n) = 4*A037314(n) = (4/3)*A208665(n).
a(n) = 4*Sum_{i=0..k} d[i]*9^i where the ternary expansion of n is n = Sum_{i=0..k} d[i]*3^i with digits d[i]=0,1,2.