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.

Previous Showing 51-60 of 354 results. Next

A360502 Concatenate the ternary strings for 1,2,...,n.

Original entry on oeis.org

1, 12, 1210, 121011, 12101112, 1210111220, 121011122021, 12101112202122, 12101112202122100, 12101112202122100101, 12101112202122100101102, 12101112202122100101102110, 12101112202122100101102110111, 12101112202122100101102110111112, 12101112202122100101102110111112120
Offset: 1

Views

Author

N. J. A. Sloane, Feb 16 2023

Keywords

Comments

If the terms are read as ternary strings and converted to base 10, we get A048435. For example, a(2) = 12_3 = 5_10, which is A048435(2). This is a prime, and gives the first term of A360503.
If the terms are read as decimal numbers, which of them are primes? 12101112202122100101102110111, for example, is not a prime, since it is 37*327057086543840543273030003.
When read as decimal numbers, the first prime is a(7315), with 56003 digits. - Michael S. Branicky, Apr 18 2023

Examples

			a(4): concatenate 1, 2, 10, 11, getting 121011.
		

Crossrefs

This is the ternary analog of A007908.

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0, (l-> parse(cat(
          a(n-1), seq(l[-i], i=1..nops(l)))))(convert(n, base, 3)))
        end:
    seq(a(n), n=1..15);  # Alois P. Heinz, Feb 17 2023
  • Mathematica
    nn = 15; s = IntegerDigits[Range[nn], 3]; Array[FromDigits[Join @@ s[[1 ;; #]]] &, nn] (* Michael De Vlieger, Apr 19 2023 *)
  • Python
    from sympy.ntheory import digits
    def a(n): return int("".join("".join(map(str, digits(k, 3)[1:])) for k in range(1, n+1)))
    print([a(n) for n in range(1, 16)]) # Michael S. Branicky, Feb 18 2023
    
  • Python
    # faster version for initial segment of sequence
    from sympy.ntheory import digits
    from itertools import count, islice
    def agen(s=""): yield from (int(s:=s+"".join(map(str, digits(n, 3)[1:]))) for n in count(1))
    print(list(islice(agen(), 15))) # Michael S. Branicky, Feb 18 2023

A097580 Base 3 representation of the concatenation of the first n numbers with the most significant digits first.

Original entry on oeis.org

1, 110, 11120, 1200201, 121221020, 20021100110, 2022201111201, 212020020002100, 22121022020212200, 1011212101120110200001, 11101000122011021220211010, 121012010100112220022220220120
Offset: 1

Views

Author

Cino Hilliard, Aug 29 2004

Keywords

Comments

Consider numbers of the form 1, 12, 123, 1234, ..., N. Find the highest power of 3^p such that 3^p <= N. Then p = [log(N)/log(3)] and for 0 <= qi <= 2 [N/3^p] = q1 + r1 [r1/3^(p-1)] = q2 + r2 ........................ rp/3^1 = qp + rp+1 rp+1/3^0 = qp+1 0 For N = 1234, p = [log(1234)/log(3)] = 6 division quot rem 1234/3^6 = 1 505 505/3^5 = 2 19 19/3^4 = 0 19 19/3^3 = 0 19 19/3^2 = 2 1 1/3^1 = 0 1 1/3^0 = 1 0 The sequence of quotients, top down, form the entry in the table for 1234. Obviously this algorithm works for any N.

Examples

			The 4th concatenation of the integers > 0 is 1234. base(10,3,1234) = 1200201 the 4th entry in the table.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[FromDigits[Flatten[Table[ IntegerDigits[n],{n,i}]]],3]],{i,12}] (* Harvey P. Dale, May 23 2011 *)

Formula

a(n) = A007089(A007908(n)). - Seiichi Manyama, Apr 23 2022

A370859 Numbers m such that c(0) < c(1) > c(2), where c(k) = number of k's in the ternary representation of m.

Original entry on oeis.org

1, 4, 10, 12, 13, 14, 16, 22, 31, 32, 34, 37, 38, 39, 40, 41, 42, 43, 46, 48, 49, 58, 64, 66, 67, 85, 91, 93, 94, 95, 97, 103, 109, 111, 112, 113, 115, 117, 118, 119, 120, 121, 122, 123, 124, 125, 127, 129, 130, 131, 133, 139, 145, 147, 148, 149, 151, 157
Offset: 1

Views

Author

Clark Kimberling, Mar 03 2024

Keywords

Examples

			The ternary representation of 16 is 121, for which c(0)=0 < c(1)=2 > c(2)=1.
		

Crossrefs

Programs

  • Maple
    filter:= proc(n) local L,m;
    L:= convert(n,base,3); m:= numboccur(1,L);
    numboccur(0,L) < m and numboccur(2,L) < m
    end proc:
    select(filter, [$1 .. 200]); # Robert Israel, Mar 03 2024
  • Mathematica
    Select[Range[1000], DigitCount[#, 3, 0] < DigitCount[#, 3, 1] > DigitCount[#, 3, 2] &]

A061392 a(n) = a(floor(n/3)) + a(ceiling(n/3)) with a(0) = 0 and a(1) = 1.

Original entry on oeis.org

0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 14, 14, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16
Offset: 0

Views

Author

Henry Bottomley, Apr 30 2001

Keywords

Comments

Number of nonnegative integers < n having no 1 in their ternary representation. - Reinhard Zumkeller, Mar 23 2003; corrected by Henry Bottomley, Mar 24 2003

Crossrefs

k appears A061393(k) times.
Essentially the partial sums of A088917.

Programs

Formula

a(n+1) + A081609(n) = n+1. - Reinhard Zumkeller, Mar 23 2003; corrected by Henry Bottomley, Mar 24 2003
From Johannes W. Meijer, Jun 05 2011: (Start)
a(3*n+1) = a(n+1) + a(n), a(3*n+2) = a(n+1) + a(n) and a(3*n+3) = 2*a(n+1), for n>=1, with a(0)=0, a(1)=1, a(2)=1 and a(3)=2. [Northshield]
G.f.: x*Product_{n>=0} (1 + x^(3^n) + 2*x^(2*3^n) + x^(3*3^n) + x^(4*3^n)). [Northshield] (End)
Apparently, for any n >= 0 and k such that n < 3^k, a(n) = 2^k * c(n / 3^k) where c is the Cantor function. - Rémy Sigrist, Jul 12 2019

A081610 Number of numbers <= n having at least one 2 in their ternary representation.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Mar 23 2003

Keywords

Comments

a(n) + A081611(n) = n+1. Partial sums of A189820.

Crossrefs

Programs

  • Maple
    num2tern := proc(n) return numboccur(convert(n,base,3),2): end: a:=0: for n from 0 to 80 do a:=a+`if`(num2tern(n)>0,1,0): printf("%d, ",a): od: # Nathaniel Johnston, May 17 2011
  • Mathematica
    Accumulate[Table[If[DigitCount[n,3,2]>0,1,0],{n,0,70}]] (* Harvey P. Dale, Aug 20 2012 *)
  • PARI
    first(n)=my(s,t); vector(n,k,t=Set(digits(k,3)); s+=t[#t]==2) \\ Charles R Greathouse IV, Sep 02 2015
    
  • Python
    from gmpy2 import digits
    def A081610(n):
        l = (s:=digits(n,3)).find('2')
        if l >= 0: s = s[:l]+'1'*(len(s)-l)
        return n-int(s,2) # Chai Wah Wu, Dec 05 2024

Formula

a(n) ~ n. - Charles R Greathouse IV, Sep 02 2015

A104320 Number of zeros in ternary representation of 2^n.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 1, 1, 1, 4, 1, 0, 4, 2, 3, 3, 3, 3, 3, 7, 7, 9, 5, 6, 6, 4, 4, 3, 5, 6, 7, 9, 9, 10, 6, 6, 9, 9, 8, 9, 8, 7, 13, 12, 13, 9, 5, 9, 8, 6, 16, 13, 9, 10, 11, 11, 7, 14, 13, 13, 9, 12, 14, 15, 15, 11, 11, 17, 15, 19, 14, 19, 12, 18, 15, 11, 10, 16, 15, 14, 14, 13, 17, 14
Offset: 0

Views

Author

Reinhard Zumkeller, Mar 01 2005

Keywords

Comments

Conjecture from N. J. A. Sloane: a(n) > 0 for n > 15, see A102483.

Examples

			n=13: 2^13=8192 -> '102020102', a(13) = 4.
		

Crossrefs

Programs

  • Magma
    [Multiplicity(Intseq(2^n,3),0):n in [0..90]]; // Marius A. Burtea, Nov 17 2019
  • Maple
    f:= n -> numboccur(0, convert(2^n,base,3)):
    map(f, [$0..100]); # Robert Israel, Nov 17 2019
  • Mathematica
    Table[DigitCount[2^n,3,0],{n,0,90}] (* Harvey P. Dale, May 06 2014 *)
  • PARI
    a(n) = my(d=vecsort(digits(2^n, 3))); #setintersect(d, vector(#d)) \\ Felix Fröhlich, Nov 17 2019
    
  • PARI
    a(n) = #select(d->!d, digits(2^n, 3)); \\ Ruud H.G. van Tol, May 09 2024
    

Formula

a(n) = A077267(A000079(n)).
a(A104321(n))=n and a(m)<>n for m < A104321(n).

A154314 Numbers with not more than two distinct digits in ternary representation.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 22, 23, 24, 25, 26, 27, 28, 30, 31, 36, 37, 39, 40, 41, 43, 44, 49, 50, 52, 53, 54, 56, 60, 62, 67, 68, 70, 71, 72, 74, 76, 77, 78, 79, 80, 81, 82, 84, 85, 90, 91, 93, 94, 108, 109, 111, 112, 117, 118, 120, 121, 122
Offset: 1

Views

Author

Reinhard Zumkeller, Jan 07 2009

Keywords

Crossrefs

Complement of A031944.
Union of A032924, A005823 and A005836.

Programs

  • Haskell
    import Data.List (findIndices)
    a154314 n = a154314_list !! (n-1)
    a154314_list = findIndices (/= 3) a212193_list
    -- Reinhard Zumkeller, May 04 2012
    
  • Mathematica
    Select[Range[0,200],Length[Union[IntegerDigits[#,3]]]<3&] (* Harvey P. Dale, Nov 23 2012 *)
  • PARI
    is(n)=#Set(digits(n,3))<3 \\ Charles R Greathouse IV, Mar 17 2014

Formula

A043530(a(n)) <= 2.
A212193(a(n)) <> 3. - Reinhard Zumkeller, May 04 2012
a(n) >> n^1.58..., where the exponent is log(3)/log(2). - Charles R Greathouse IV, Mar 17 2014
Sum_{n>=2} 1/a(n) = 5.47555542241781419692840472181029603722178623821762258873485212626135391726959422416350447132335696748507... (calculated using Baillie and Schmelzer's kempnerSums.nb, see Links). - Amiram Eldar, Apr 14 2025

A163325 Pick digits at the even distance from the least significant end of the ternary expansion of n, then convert back to decimal.

Original entry on oeis.org

0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 6, 7, 8, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 6, 7, 8, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 6, 7, 8, 9, 10, 11, 9, 10, 11, 9, 10, 11, 12, 13, 14, 12, 13, 14
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			11 in ternary base (A007089) is written as '102' (1*9 + 0*3 + 2), from which we pick the "zeroth" and 2nd digits from the right, giving '12' = 1*3 + 2 = 5, thus a(11) = 5.
		

Crossrefs

A059905 is an analogous sequence for binary.

Programs

  • PARI
    a(n) = fromdigits(digits(n,9)%3,3); \\ Kevin Ryde, May 14 2020

Formula

a(0) = 0, a(n) = (n mod 3) + 3*a(floor(n/9)).
a(n) = Sum_{k>=0} {A030341(n,k)*b(k)} where b is the sequence (1,0,3,0,9,0,27,0,81,0,243,0... = A254006): powers of 3 alternating with zeros. - Philippe Deléham, Oct 22 2011
A037314(a(n)) + 3*A037314(A163326(n)) = n for all n.

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A163328 Square array A, where entry A(y,x) has the ternary digits of x interleaved with the ternary digits of y, converted back to decimal. Listed by antidiagonals: A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), A(2,0), ...

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			From _Kevin Ryde_, Oct 06 2020: (Start)
Array A(y,x) read by downwards antidiagonals, so 0, 1,3, 2,4,6, etc.
        x=0   1   2   3   4   5   6   7   8
      +--------------------------------------
  y=0 |   0,  1,  2,  9, 10, 11, 18, 19, 20,
    1 |   3,  4,  5, 12, 13, 14, 21, 22,
    2 |   6,  7,  8, 15, 16, 17, 24,
    3 |  27, 28, 29, 36, 37, 38,
    4 |  30, 31, 32, 39, 40,
    5 |  33, 34, 35, 42,
    6 |  54, 55, 56,
    7 |  57, 58,
    8 |  60,
(End)
		

Crossrefs

Inverse: A163329. Transpose: A163330. Cf. A037314 (row y=0), A208665 (column x=0)
Cf. A054238 is an analogous sequence for binary. Cf. A007089, A163327, A163332, A163334.

Programs

Formula

a(n) = A037314(A025581(n)) + 3*A037314(A002262(n))
a(n) = A163327(A163330(n)).

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A171960 Values of the 2-complement of n in ternary representation.

Original entry on oeis.org

2, 1, 0, 5, 4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 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, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 20 2010

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := 3^(1 + Floor[Log[3, n]]) - n - 1; a[0] = 2; Array[a, 100] (* Amiram Eldar, Apr 03 2025 *)
  • PARI
    a(n) = 3^(if(n,logint(n,3))+1) - 1 - n; \\ Kevin Ryde, Jul 16 2020

Formula

a(n) = if n < 3 then 2 - n else 3*a(floor(n/3)) + 2 - n mod 3.
a(A134026(n)) < A134026(n).
a(A003462(n)) = A003462(n).
a(A134025(n)) >= A134025(n).
Previous Showing 51-60 of 354 results. Next