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.

Showing 1-7 of 7 results.

A372317 For any n > 0 with leading ternary digit h = A122586(n), reverse digits in blocks in ternary expansion of n where blocks are separated by h's; a(0) = 0.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 12, 13, 14, 11, 16, 17, 18, 21, 20, 19, 22, 23, 24, 25, 26, 27, 28, 45, 30, 31, 32, 33, 46, 51, 36, 37, 42, 39, 40, 41, 38, 43, 44, 29, 34, 47, 48, 49, 50, 35, 52, 53, 54, 63, 56, 57, 66, 65, 60, 61, 62, 55, 64, 59, 58, 67
Offset: 0

Views

Author

Rémy Sigrist, Apr 27 2024

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.
This sequence has infinitely many fixed points (A125292, among others).

Examples

			For n = 5323: the ternary expansion of 5323 is "21022011", the corresponding leading digit is "2", we have three blocks: "10", "" and "011", their reversals are: "01", "" and "110", so the ternary expansion of a(5323) is "20122110", and a(5323) = 4845.
		

Crossrefs

See A367307 and A372318 for similar sequences.

Programs

  • PARI
    a(n, base = 3) = { my (d = digits(n, base), i = 1); 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, base); }

A261237 Number of steps needed when starting from (3^(n+1))-1 and repeatedly applying the map that replaces k with k - (sum of digits in base-3 representation of k) to encounter the first number whose base-3 representation begins with a digit other than 2.

Original entry on oeis.org

1, 1, 2, 5, 13, 34, 92, 251, 687, 1885, 5184, 14292, 39557, 110094, 308351, 868716, 2458964, 6984467, 19890809, 56775186, 162427605, 465816503, 1339163192, 3858600035, 11138726760, 32199805820
Offset: 0

Views

Author

Antti Karttunen, Aug 16 2015

Keywords

Comments

a(n) = How many numbers whose base-3 representation begins with digit "2" are encountered before (3^n)-1 is reached when starting from k = (3^(n+1))-1 and repeatedly applying the map that replaces k by k - (sum of digits in base-3 representation of k). Note that (3^n)-1 (in base-3: "222...", with digit "2" repeated n times) is not included in the count, although the starting point (3^(n+1))-1 is.

Examples

			For n=0, we start from 3^(0+1) - 1 = 2 (also "2" in base-3), and subtract 2 to get 0, which doesn't begin with 2, thus a(0) = 1.
For n=1, we start from 3^(1+1) - 1 = 8 ("22" in base-3), and subtract 2*2 = 4 to get 4 ("11" in base-3) which doesn't begin with 2, thus a(1) = 1.
For n=2, we start from 3^(2+1) - 1 = 26 ("222" in base-3), and subtract first 6 to get 20 ("202" in base-3), from which we subtract 4, to get 16 ("121" in base-3), so in two steps we have reached the first such number that does not begin with "2" in base-3, thus a(2) = 2.
		

Crossrefs

Programs

  • C
    /* Use the C-program given in A261234. */
    
  • Mathematica
    Flatten@ Table[FirstPosition[#, k_ /; k != 2] &@ Map[First@ IntegerDigits[#, 3] &, NestWhileList[# - Total@ IntegerDigits[#, 3] &, 3^(n + 1) - 1, # > 3^n - 1 &]] - 1, {n, 0, 16}] (* Michael De Vlieger, Jun 27 2016, Version 10 *)
  • PARI
    a(n)=my(k=3^(n+1)-1,t=2*3^n,s); while(k>=t, k-=sumdigits(k,3); s++); s \\ Charles R Greathouse IV, Aug 21 2015
  • Scheme
    (definec (A261237 n) (let loop ((k (- (A000244 (+ 1 n)) 1)) (s 0)) (if (< (A122586 k) 2) s (loop (* 2 (A054861 k)) (+ 1 s)))))
    

Extensions

Terms a(24) & a(25) from Antti Karttunen, Jun 27 2016

A361945 If the ternary expansion of n starts with the digit 1, then replace 2's by 0's and vice versa; if the ternary expansion of n starts with the digit 2, then replace 1's by 0's and vice versa; a(0) = 0.

Original entry on oeis.org

0, 1, 2, 5, 4, 3, 7, 6, 8, 17, 16, 15, 14, 13, 12, 11, 10, 9, 22, 21, 23, 19, 18, 20, 25, 24, 26, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 67, 66, 68, 64, 63, 65, 70, 69, 71, 58, 57, 59, 55, 54
Offset: 0

Views

Author

Rémy Sigrist, Mar 31 2023

Keywords

Comments

Leading zeros in ternary expansions are ignored.
This sequence is a self-inverse permutation of the nonnegative integers.

Examples

			The first terms, in decimal and in ternary, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2       2          2
   3     5      10         12
   4     4      11         11
   5     3      12         10
   6     7      20         21
   7     6      21         20
   8     8      22         22
   9    17     100        122
  10    16     101        121
  11    15     102        120
  12    14     110        112
  13    13     111        111
  14    12     112        110
  15    11     120        102
		

Crossrefs

Cf. A048328 (fixed points), A122586, A171960.

Programs

  • PARI
    a(n) = { my (d = digits(n, 3), m); if (#d==0, m = [0,1,2], d[1]==1, m = [2,1,0], m = [1,0,2]); fromdigits(apply(t -> m[1+t], d), 3); }

Formula

a(n) = n iff n belongs to A048328.
a(n) = A171960(n) when A122586(n) = 1.

A339255 Leading digit of n in base 5.

Original entry on oeis.org

1, 2, 3, 4, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
Offset: 1

Views

Author

Kevin Ryde, Nov 28 2020

Keywords

Crossrefs

Cf. A007091 (base 5), A073851 (partial sums).

Programs

  • Mathematica
    IntegerDigits[#,5][[1]]&/@Range[100] (* Harvey P. Dale, Sep 04 2021 *)
  • PARI
    a(n) = n\5^logint(n,5);

Formula

a(n) = floor(n / 5^floor(log_5(n))).
G.f.: (x + Sum_{k>=0} Sum_{d=2..4} (x^(d*5^k)-x^(5^(k+1))) )/(1-x).

A339256 Leading digit of n in base 6.

Original entry on oeis.org

1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
Offset: 1

Views

Author

Kevin Ryde, Nov 28 2020

Keywords

Crossrefs

Cf. A007092 (base 6), A109804 (partial sums).

Programs

  • Mathematica
    Table[IntegerDigits[n,6][[1]],{n,90}] (* Harvey P. Dale, Jul 19 2023 *)
  • PARI
    a(n) = n\6^logint(n,6);

Formula

a(n) = floor(n / 6^floor(log_6(n))).
G.f.: (x + Sum_{k>=0} Sum_{d=2..5} (x^(d*6^k)-x^(6^(k+1))) )/(1-x).

A370932 For any number n >= 0 with ternary expansion Sum_{i >= 0} t_i * 3^i, a(n) = Sum_{i >= 0} ((Sum_{j >= 0} (-1)^j * t_{i+j}) mod 3) * 3^i.

Original entry on oeis.org

0, 1, 2, 5, 3, 4, 7, 8, 6, 16, 17, 15, 9, 10, 11, 14, 12, 13, 23, 21, 22, 25, 26, 24, 18, 19, 20, 50, 48, 49, 52, 53, 51, 45, 46, 47, 27, 28, 29, 32, 30, 31, 34, 35, 33, 43, 44, 42, 36, 37, 38, 41, 39, 40, 70, 71, 69, 63, 64, 65, 68, 66, 67, 77, 75, 76, 79, 80
Offset: 0

Views

Author

Rémy Sigrist, Mar 06 2024

Keywords

Comments

In other words, the k-th ternary digit of a(n) is congruent (modulo 3) to the alternate sum of the digits to the left of (and including) the k-th ternary digit of n.
This sequence is a permutation of the nonnegative integers with inverse A071770 that preserves the number of ternary digits (A081604) and the leading ternary digit (A122586).

Examples

			For n = 42: the ternary expansion of 42 is "1120"; also:
     + 1             = 1 (mod 3)
     - 1 + 1         = 0 (mod 3)
     + 1 - 1 + 2     = 2 (mod 3)
     - 1 + 1 - 2 + 0 = 1 (mod 3)
- so the ternary expansion of a(42) is "1021", and a(42) = 34.
		

Crossrefs

Cf. A006068 (base-2 analog), A081604, A105529, A122586, A071770 (inverse).

Programs

  • PARI
    a(n, base = 3) = { my (d = digits(n, base), s = 0); for (i = 1, #d, d[i] = (s = d[i]-s) % base;); fromdigits(d, base); }
    
  • Python
    from itertools import accumulate
    from sympy.ntheory import digits
    def A370932(n):
        t = accumulate(((-j if i&1 else j) for i, j in enumerate(digits(n,3)[1:])),func=lambda x,y: (x+y)%3)
        return int(''.join(str(-d%3 if i&1 else d) for i,d in enumerate(t)),3) # Chai Wah Wu, Mar 08 2024

Formula

A081604(a(n)) = A081604(n).
A122586(a(n)) = A122586(n).

A273619 Table read by antidiagonals (n>1, k>0): A(n,k) = leading digit of k in base n.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1, 2, 3, 1, 1, 1, 1, 2, 3, 4, 1, 2, 1, 1, 2, 3, 4, 1, 1, 2, 1, 1, 2, 3, 4, 5, 1, 1, 2, 1, 1, 2, 3, 4, 5, 1, 1, 2, 1, 1, 1, 2, 3, 4, 5, 6, 1, 1, 2, 1, 1, 1, 2, 3, 4, 5, 6, 1, 1, 1, 2, 1, 1, 1, 2, 3, 4, 5, 6, 7, 1
Offset: 2

Views

Author

Andrey Zabolotskiy, May 30 2016

Keywords

Comments

This is a generalization of A000030.
The first occurrence of a number k in the sequence is given by A(k+1,k).

Examples

			First few rows of the array are:
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2...
1, 2, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1...
1, 2, 3, 4, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3...
1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3...
1, 2, 3, 4, 5, 6, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2...
1, 2, 3, 4, 5, 6, 7, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2...
Note that the initial row is row 2.
A(3,3) corresponds to row n=3 and column k=3, and k=3 is written as 10 in base n=3, and the leading digit of 10 is 1, so A(3,3)=1.
A(12,11) corresponds to row n=12 and column k=11, and 11 is written as B in base 12, and the leading and only digit of B is B which is number 11 in decimal, so A(12,11)=11.
		

Crossrefs

Cf. A000030 (row 10), A122586 (row 3), A122587 (row 4).
Cf. A051777, A051778 (may be interpreted as arrays of last digits of k in base n).

Programs

  • Maple
    A:= (n,k) -> floor(k/n^floor(log[n](k))):
    seq(seq(A(n-k,k),k=1..n-2),n=2..20); # Robert Israel, May 31 2016
  • Mathematica
    a[n_, k_] := First[IntegerDigits[k, n]];
  • PARI
    T(n,k) = digits(k, n)[1];
    tabl(10, 10, n, k, n++; T(n,k)); \\ Michel Marcus, Jun 12 2016

Formula

From Robert Israel, May 31 2016: (Start)
A(n,k) = floor(k/n^floor(log_n(k))).
A(n,k) = k if n > k.
A(n,k) = A(n, floor(k/n)) otherwise.
G.f. of row n, G_n(x), satisfies G_n(x) = (1-x^n)/(1-x)^2 - (1+(n-1)*x^n)/(1-x) + (1-x^n)*G_n(x^n)/(1-x). (End)
Showing 1-7 of 7 results.