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-3 of 3 results.

A007089 Numbers in base 3.

Original entry on oeis.org

0, 1, 2, 10, 11, 12, 20, 21, 22, 100, 101, 102, 110, 111, 112, 120, 121, 122, 200, 201, 202, 210, 211, 212, 220, 221, 222, 1000, 1001, 1002, 1010, 1011, 1012, 1020, 1021, 1022, 1100, 1101, 1102, 1110, 1111, 1112, 1120, 1121, 1122, 1200, 1201, 1202, 1210, 1211
Offset: 0

Views

Author

Keywords

Comments

Nonnegative integers with no decimal digit > 2. Thus nonnegative integers in base 10 whose quadrupling by normal addition or multiplication requires no carry operation. - Rick L. Shepherd, Jun 25 2009

References

  • Jan Gullberg, Mathematics from the Birth of Numbers, W. W. Norton & Co., NY & London, 1997, ยง2.3 Positional Notation, p. 47.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a007089 0 = 0
    a007089 n = 10 * a007089 n' + m where (n', m) = divMod n 3
    -- Reinhard Zumkeller, Feb 19 2012
    
  • Maple
    A007089 := proc(n) option remember;
    if n <= 0 then 0
    else
      if (n mod 3) = 0 then 10*procname(n/3) else procname(n-1) + 1 fi
    fi end:
    [seq(A007089(n), n=0..729)]; # - N. J. A. Sloane, Mar 09 2019
  • Mathematica
    Table[ FromDigits[ IntegerDigits[n, 3]], {n, 0, 50}]
  • PARI
    a(n)=if(n<1,0,if(n%3,a(n-1)+1,10*a(n/3)))
    
  • PARI
    a(n)=fromdigits(digits(n,3)) \\ Charles R Greathouse IV, Jan 08 2017
    
  • Python
    def A007089(n):
      n,s = divmod(n,3); t = 1
      while n: n,r = divmod(n,3); t *= 10; s += r*t
      return s # M. F. Hasler, Feb 15 2023

Formula

a(0)=0, a(n) = 10*a(n/3) if n==0 (mod 3), a(n) = a(n-1) + 1 otherwise. - Benoit Cloitre, Dec 22 2002
a(n) = 10*a(floor(n/3)) + (n mod 3) if n > 0, a(0) = 0. - M. F. Hasler, Feb 15 2023

Extensions

More terms from James Sellers, May 01 2000

A065721 Primes p whose base-3 expansion is also the decimal expansion of a prime.

Original entry on oeis.org

2, 67, 79, 103, 139, 157, 181, 193, 199, 211, 229, 277, 283, 307, 313, 349, 367, 373, 409, 421, 433, 439, 463, 523, 541, 547, 571, 577, 751, 829, 883, 919, 1021, 1033, 1039, 1087, 1171, 1249, 1303, 1429, 1483, 1579, 1597, 1621, 1741, 1783, 1789, 1873
Offset: 1

Views

Author

Patrick De Geest, Nov 15 2001

Keywords

Comments

In general rebase notation (Marc LeBrun): p3 = (3) [p] (10).

Examples

			1033_10 = 1102021_3 is prime, and so is 1102021_10.
		

Crossrefs

Primes in A036954.
Cf. A065720 up to A065727, A065361. See the Links for further cross-references.

Programs

  • Mathematica
    Select[ Range[1900], PrimeQ[ # ] && PrimeQ[ FromDigits[ IntegerDigits[ #, 3]]] & ]
  • PARI
    is(p,b=10,c=3)=isprime(vector(#c=digits(p,c),i,b^(#c-i))*c~)&&isprime(p) \\ M. F. Hasler, Jan 12 2014

Extensions

Definition clarified by M. F. Hasler, Jan 12 2014

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
Showing 1-3 of 3 results.