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-10 of 42 results. Next

A193581 Sort-and-subtract: a(n) = n - A004185(n).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 9, 0, 0, 0, 0, 0, 0, 0, 0, 27, 18, 9, 0, 0, 0, 0, 0, 0, 0, 36, 27, 18, 9, 0, 0, 0, 0, 0, 0, 45, 36, 27, 18, 9, 0, 0, 0, 0, 0, 54, 45, 36, 27, 18, 9, 0, 0, 0, 0, 63, 54, 45, 36, 27, 18, 9, 0, 0
Offset: 0

Views

Author

Reinhard Zumkeller, Aug 10 2011

Keywords

Crossrefs

Programs

  • Haskell
    a193581 n = n - a004185 n
    a193581_list = map a193581 [0..]
  • Mathematica
    ss[n_]:=n-FromDigits[Sort[Select[IntegerDigits[n],#>0&]]]; Array[ss,80,0] (* Harvey P. Dale, Aug 13 2013 *)

Formula

a(A009994(n)) = 0.
For n > 10, a(A009995(n)) > 0.

A096091 Numbers n with property that largest number formed from digits of n (A004186(n)) is divisible by smallest number formed from digits of n (A004185(n)).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 22, 30, 33, 40, 44, 50, 55, 60, 66, 70, 77, 80, 88, 90, 99, 100, 101, 105, 108, 110, 111, 150, 180, 200, 202, 220, 222, 300, 303, 330, 333, 400, 404, 405, 440, 444, 450, 500, 501, 504, 505, 510, 540, 550, 555, 600, 606
Offset: 1

Views

Author

Amarnath Murthy, Jun 22 2004

Keywords

Comments

The number N = d*10^m*(10^k-1)/9 is a member for all m, k where 1 < d < 10, since the quotient is 10^m. E.g., for d = 7, m = 4, k = 8 we get N = 777777770000.
Conjecture: There are infinitely many terms besides these.
From Jon E. Schoenfield, Jul 26 2015: (Start)
Every number whose nonzero digits are all identical (e.g., 70770070777) is a term in the sequence (so the sequence is infinite). Also, if k is a term, then so is k*10 (hence, so is k*10^m for m >= 1). Removal of all terms that satisfy either of the above criteria still leaves an infinite number of terms, beginning with 105, 108, 150, 180, 405, 450, 501, 504, 510, 540, 801, 810, ... (see A260461).
If any integer k is a term, then so is every integer obtained by permuting the digits of k, except for some (not necessarily all) permutations beginning with 0. E.g., since 12000 is a member, so are all the other permutations of its digits that begin with 1 (i.e., 10002, 10020, and 10200), and all those that begin with 2 (i.e., 20001, 20010, 20100, and 21000), as well as the permutations that begin with a single 0 (which, after leading zeros are removed, reduce to 1002, 1020, 1200, 2001, 2010, and 2100), but not those that begin with more than one 0 (i.e., the sequence does not include 12, 21, 102, 120, 201, or 210). Aside from those terms whose nonzero digits are all identical, it appears that only a small number of patterns result from sorting the digits in increasing order (and discarding the zeros, which, of course, are all leading zeros): these "primitives" begin with 12, 15, 16, 18, 24, 25, 36, 45, 48, 125, ... (see A260462). (End)

Examples

			110 is a member as 110/011=10.
		

Crossrefs

Programs

  • Maple
    isA096091 := proc(n)
        if modp( A004186(n),A004185(n))= 0 then
            true;
        else
            false;
        end if;
    end proc:
    for n from 1 to 1000 do
        if isA096091(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, Jul 26 2015
  • Mathematica
    Select[Range[999], (d = Sort@ IntegerDigits@ #; Divisible@@ FromDigits/@ {Reverse@ d, d})&] (* Giovanni Resta, Jul 26 2015 *)

Extensions

Edited, corrected and extended by Robert G. Wilson v, Jun 23 2004
Entry revised by Editors of the OEIS, Jul 26 2015

A345681 a(0) = 0; for n >= 1, a(n) = A004185(a(n-1)+n).

Original entry on oeis.org

0, 1, 3, 6, 1, 6, 12, 19, 27, 36, 46, 57, 69, 28, 24, 39, 55, 27, 45, 46, 66, 78, 1, 24, 48, 37, 36, 36, 46, 57, 78, 19, 15, 48, 28, 36, 27, 46, 48, 78, 118, 159, 12, 55, 99, 144, 19, 66, 114, 136, 168, 129, 118, 117, 117, 127, 138, 159, 127, 168
Offset: 0

Views

Author

Ctibor O. Zizka, Jun 22 2021

Keywords

Examples

			a(4) = A004185(6+4) = 1; a(13) = A004185(69+13) = 28.
		

Crossrefs

Programs

  • Mathematica
    a[0] := 0;
    a[n_] := FromDigits[Sort[DeleteCases[IntegerDigits[a[n - 1] + n], 0]]];
    Table[a[n], {n, 0, 59}] (* Robert P. P. McKone, Aug 16 2021 *)
  • PARI
    f(n) = fromdigits(vecsort(digits(n))); \\ A004185
    a(n) = if (n==0, 0, f(a(n-1)+n)); \\ Michel Marcus, Jun 26 2021
    
  • PARI
    f(n) = fromdigits(vecsort(digits(n))); \\ A004185
    lista(nn) = {my(v=vector(nn)); v[1] = 1; for (n=2, nn, v[n] = f(v[n-1]+n);); concat(0, v);} \\ Michel Marcus, Jun 26 2021
  • Python
    def A004185(n): return int("".join(sorted(str(n))).strip('0'))
    def aupton(nn):
        alst = [0]
        for n in range(1, nn+1): alst.append(A004185(alst[-1]+n))
        return alst
    print(aupton(100)) # Michael S. Branicky, Jun 22 2021
    

Formula

a(9*k+0 or 8) == 0 (mod 9);
a(9*k+1 or 4 or 7) == 1 (mod 9);
a(9*k+2 or 6) == 3 (mod 9);
a(9*k+3 or 5) == 6 (mod 9).

A345902 a(0) = 1; for n >= 1, a(n) = A004185(a(n-1)*n).

Original entry on oeis.org

1, 1, 2, 6, 24, 12, 27, 189, 1125, 1125, 1125, 12357, 124488, 1134468, 12255588, 12333888, 12234789, 11234799, 22222368, 222224499, 444448899, 2333467899, 12333567789, 12234567789, 222336666999, 1445555667789, 12334444556778, 33333336, 33333489, 111666789
Offset: 0

Views

Author

Ctibor O. Zizka, Jun 29 2021

Keywords

Comments

Rearranging of digits of a(n-1)*n in ascending order gives in step n the smallest number possible. For n >= 5; the number of digits of a(n) < the number of digits of n!.

Examples

			a(4) = A004185(4*6) = 24; a(5) = A004185(5*24) = 12; a(6) = A004185(6*12) = 27.
		

Crossrefs

Programs

  • PARI
    f(n) = fromdigits(vecsort(digits(n))); \\ A004185
    a(n) = if (n, f(a(n-1)*n), 1); \\ Michel Marcus, Jun 30 2021
  • Python
    def A004185(n):
        return 0 if n == 0 else int("".join(sorted(str(n))).strip('0'))
    def aupton(nn):
        alst = [1]
        for n in range(1, nn+1): alst.append(A004185(alst[-1]*n))
        return alst
    print(aupton(29)) # Michael S. Branicky, Jun 29 2021
    

A004086 Read n backwards (referred to as R(n) in many sequences).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 7, 17, 27, 37, 47
Offset: 0

Views

Author

Keywords

Comments

Also called digit reversal of n.
Leading zeros (after the reversal has taken place) are omitted. - N. J. A. Sloane, Jan 23 2017

Crossrefs

Programs

  • Haskell
    a004086 = read . reverse . show  -- Reinhard Zumkeller, Apr 11 2011
    
  • J
    |.&.": i.@- 1e5 NB. Stephen Makdisi, May 14 2018
  • Maple
    read transforms; A004086 := digrev; #cf "Transforms" link at bottom of page
    A004086:=proc(n) local s,t; if n<10 then n else s:=irem(n,10,'t'); while t>9 do s:=s*10+irem(t,10,'t') od: s*10+t fi end; # M. F. Hasler, Jan 29 2012
  • Mathematica
    Table[FromDigits[Reverse[IntegerDigits[n]]], {n, 0, 75}]
    IntegerReverse[Range[0,80]](* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 13 2018 *)
  • PARI
    dig(n) = {local(m=n,r=[]); while(m>0,r=concat(m%10,r);m=floor(m/10));r}
    A004086(n) = {local(b,m,r);r=0;b=1;m=dig(n);for(i=1,matsize(m)[2],r=r+b*m[i];b=b*10);r} \\ Michael B. Porter, Oct 16 2009
    
  • PARI
    A004086(n)=fromdigits(Vecrev(digits(n))) \\ M. F. Hasler, Nov 11 2010, updated May 11 2015, Sep 13 2019
    
  • Python
    def A004086(n):
        return int(str(n)[::-1]) # Chai Wah Wu, Aug 30 2014
    

Formula

For n > 0, a(a(n)) = n iff n mod 10 != 0. - Reinhard Zumkeller, Mar 10 2002
a(n) = d(n,0) with d(n,r) = r if n=0, otherwise d(floor(n/10), r*10+(n mod 10)). - Reinhard Zumkeller, Mar 04 2010
a(10*n+x) = x*10^m + a(n) if 10^(m-1) <= n < 10^m and 0 <= x <= 9. - Robert Israel, Jun 11 2015

Extensions

Extended by Ray Chandler, Dec 30 2004

A009994 Numbers with digits in nondecreasing order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 33, 34, 35, 36, 37, 38, 39, 44, 45, 46, 47, 48, 49, 55, 56, 57, 58, 59, 66, 67, 68, 69, 77, 78, 79, 88, 89, 99, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122
Offset: 1

Views

Author

Keywords

Comments

Record values and occurrences of A004185. - Reinhard Zumkeller, Dec 05 2009
A193581(a(n)) = 0. - Reinhard Zumkeller, Aug 10 2011
This sequence was used by the U.S. Bureau of the Census in the mid-1950s to numerically code the alphabetical list of counties within a state (with some modifications for Texas). The 3-digit code has a "self-policing element" built into it and "was fairly effective in detecting the transposition of 2 digits." (Hanna 1959). - Randy A. Becker, Dec 11 2017

References

  • Amarnath Murthy and Robert J. Clarke, Some Properties of Staircase sequence, Mathematics & Informatics Quarterly, Volume 11, No. 4, November 2001.
  • Frank A. Hanna, The Compilation of Manufacturing Statistics. U.S. Department of Commerce, Bureau of the Census, 1959.

Crossrefs

Apart from the first term, a subsequence of A052382. A254143 is a subsequence.

Programs

  • Haskell
    import Data.Set (fromList, deleteFindMin, insert)
    a009994 n = a009994_list !! n
    a009994_list = 0 : f (fromList [1..9]) where
       f s = m : f (foldl (flip insert) s' $ map (10*m +) [m `mod` 10 ..9])
             where (m,s') = deleteFindMin s
    -- Reinhard Zumkeller, Aug 10 2011
    
  • Magma
    [k:k in [0..122]|Sort(Intseq(k)) eq Reverse(Intseq(k))]; // Marius A. Burtea, Jul 28 2019
    
  • Maple
    A[0]:= [0]: A[1]:= [$1..9]:
    for d from 2 to 4 do
      A[d]:= map(t -> seq(10*t+i,i=(t mod 10) .. 9), A[d-1]):
    od:
    seq(op(A[d]),d=0..4); # Robert Israel, Jul 28 2019
  • Mathematica
    Select[Range[0, 125], LessEqual@@IntegerDigits[#] &] (* Ray Chandler, Oct 25 2011 *)
  • PARI
    is(n)=n=digits(n);n==vecsort(n) \\ Charles R Greathouse IV, Dec 03 2013
    
  • Python
    from itertools import combinations_with_replacement
    def A009994generator():
        yield 0
        l = 1
        while True:
            for i in combinations_with_replacement('123456789',l):
                yield int(''.join(i))
            l += 1 # Chai Wah Wu, Nov 11 2015
    
  • Scala
    def hasDigitsSorted(n: Int): Boolean = {
      val digSort = Integer.parseInt(n.toString.toCharArray.sorted.mkString)
      n == digSort
    }
    (0 to 200).filter(hasDigitsSorted()) // _Alonso del Arte, Apr 20 2020

Formula

a(n) >> exp(n^(1/10)). - Charles R Greathouse IV, Mar 15 2014
a(n) ~ 10^((9! n)^(1/9) - 5), since 10^(d - 1) <= a(n) < 10^d for binomial(d + 8, 9) < n <= binomial(d + 9, 9) = (d + 5 - epsilon)^9 / 9!. Using epsilon = 10/(3n) + o(1/n) gives more precise estimate. [Following Radcliffe and McKay, cf. SeqFan list.] - M. F. Hasler, Jul 30 2019

A151949 a(n) = image of n under the Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 18, 27, 36, 45, 54, 63, 72, 18, 9, 0, 9, 18, 27, 36, 45, 54, 63, 27, 18, 9, 0, 9, 18, 27, 36, 45, 54, 36, 27, 18, 9, 0, 9, 18, 27, 36, 45, 45, 36, 27, 18, 9, 0, 9, 18, 27, 36, 54, 45, 36, 27, 18, 9, 0, 9, 18, 27, 63, 54, 45, 36, 27, 18, 9, 0, 9, 18, 72, 63, 54, 45, 36, 27, 18, 9, 0, 9, 81, 72, 63, 54, 45, 36, 27, 18, 9, 0, 99, 99, 198, 297, 396, 495, 594, 693, 792, 891, 99, 0, 99, 198, 297, 396, 495, 594, 693, 792
Offset: 0

Views

Author

N. J. A. Sloane, Aug 18 2009

Keywords

Comments

Entries are multiples of 9 - see A151950.
a(n) = A004186(n) - A004185(n); a(A010785(n)) = 0. - Reinhard Zumkeller, corrected: Mar 23 2015, Jul 09 2013

Examples

			For n = 15, a(15) = 51 - 15 = 36. - _Indranil Ghosh_, Feb 01 2017
		

Crossrefs

In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9). - Joseph Myers, Sep 05 2009
Cf. also A004185, A004186, A099009 (fixed points).

Programs

  • Haskell
    a151949 n = a004186 n - a004185 n
    -- Reinhard Zumkeller, corrected: Mar 23 2015, Jul 09 2013
    
  • Mathematica
    f[n_] := Module[{idn = IntegerDigits@n, idns}, idns = Sort@ idn; FromDigits@ Reverse@ idns - FromDigits@ idns]; Table[ f@n, {n, 0, 200}] (* Harvey P. Dale, Aug 18 2009 *)
    Flatten[Table[Differences[FromDigits /@ {y = Sort[x = IntegerDigits[n]], Reverse[y]}], {n, 0, 74}]] (* Jayanta Basu, Jul 11 2013 *)
  • PARI
    a(n) = {my(d=digits(n)); fromdigits(vecsort(d,,4)) - fromdigits(vecsort(d));} \\ Michel Marcus, Dec 08 2019
  • Python
    def A151949(n):
        return int("".join(sorted(str(n),reverse=True)))-int("".join(sorted(str(n)))) # Indranil Ghosh, Feb 01 2017
    

Extensions

More terms from Robert G. Wilson v, Aug 19 2009
More than the usual number of terms are shown in order to distinguish this from similar sequences. - N. J. A. Sloane, Sep 22 2021

A099009 Fixed points of the Kaprekar mapping f(n) = n' - n'', where in n' the digits of n are arranged in descending, in n'' in ascending order.

Original entry on oeis.org

0, 495, 6174, 549945, 631764, 63317664, 97508421, 554999445, 864197532, 6333176664, 9753086421, 9975084201, 86431976532, 555499994445, 633331766664, 975330866421, 997530864201, 999750842001, 8643319766532, 63333317666664
Offset: 1

Views

Author

Klaus Brockhaus, Sep 22 2004

Keywords

Comments

There are no seven-digit fixed points.
Let d(n) denote n repetitions of the digit d. The sequence includes the following for all n>=0: 5(n)499(n)4(n)5, 63(n)176(n)4, 8643(n)1976(n)532. - Jens Kruse Andersen, Oct 04 2004
0's in n giving leading 0's in n'' is allowed.
For every natural number n let n' and n" be the numbers obtained by arranging the digits of n into decreasing and increasing order, and let f(n)=n'-n". It is known that the number 6174 is invariant under this transformation and that applying f a certain number of times to a number n with four digits the numbers 0, 495 or 6174 are always reached. - Vincenzo Librandi, Nov 17 2010
Each term of A055162(n) corresponds to A099009(n+1), with its digits being reordered in the ascending manner. - Alexander R. Povolotsky, Apr 27 2012
All terms of this sequence are divisible by nine, a(n)/9 = A132155(n). - Alexander R. Povolotsky, Apr 29 2012
A055160 differs from this sequence only at the positions of two terms in it: 554999445 and 555499994445. - Alexander R. Povolotsky, May 01 2012
The union of the sequences A214555, A214556, A214557, A214558, A214559 and the element 0 gives the sequence A099009. - Syed Iddi Hasan, Jul 24 2012
The comment made by Jens Kruse Andersen is missing one more family of terms (which starts with one or more digits "9" and ends with the digit "1"): 97508421, 9753086421, 9975084201, 975330866421, 997530864201, 999750842001, ... This family could be generalized (using the same method as in Andersen's comment) and it is actually covered by Syed Iddi Hasan in A214559. Also A214557 and A214558 (both - by Syed Iddi Hasan) are variants of Andersen's 8643(n)1976(n)532. - Alexander R. Povolotsky, Mar 14 2015
Fixed points of A151949. - Reinhard Zumkeller, Mar 23 2015

Examples

			6174 is a fixed point of the mapping and hence a term: 6174 -> 7641 - 1467 = 6174.
		

Crossrefs

In other bases: A163205 (base 2), A164997 (base 3), A165016 (base 4), A165036 (base 5), A165055 (base 6), A165075 (base 7), A165094 (base 8), A165114 (base 9).

Programs

  • Haskell
    a099009 n = a099009_list !! (n-1)
    a099009_list = [x | x <- [0..], a151949 x == x]
    -- Reinhard Zumkeller, Mar 23 2015
    
  • Magma
    a:=func; [k:k in [0..10^7]|a(k)]; // Marius A. Burtea, Sep 12 2019
  • Mathematica
    f[n_] := Block[{d = IntegerDigits@ n, a, b}, a = FromDigits@ Sort@ d; b = FromDigits@ Reverse@ Sort@ d; n == b - a]; Select[Range@ 1000000, f] (* Michael De Vlieger, Mar 20 2015 *)
  • Python
    # (version 2.4) from Tim Peters
    def extend(base, start, n):
        if n == 0:
            yield base
            return
        for i in range(start, 10):
            for x in extend(base + str(i), i, n-1):
                yield x
    def drive(n):
        result = []
        for lo in extend("", 0, n):
            ilo = int(lo)
            if ilo == 0 and n > 1:
                continue
            hi = lo[::-1]
            diff = str(int(hi) - ilo)
            diff = "0" * (n - len(diff)) + diff
            if sorted(diff) == list(lo):
                result.append(diff)
        return sorted(result)
    for n in range(1, 17):
        # print("Length", n)
        # print('-' * 40)
        for r in drive(n):
            print(r, end=', ')
    

Extensions

More terms from Jens Kruse Andersen and Tim Peters (tim(AT)python.org), Oct 04 2004
Corrected by Jens Kruse Andersen, Oct 25 2004

A004186 Arrange digits of n in decreasing order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 41, 51, 61, 71, 81, 91, 20, 21, 22, 32, 42, 52, 62, 72, 82, 92, 30, 31, 32, 33, 43, 53, 63, 73, 83, 93, 40, 41, 42, 43, 44, 54, 64, 74, 84, 94, 50, 51, 52, 53, 54, 55, 65, 75, 85, 95, 60, 61, 62, 63, 64, 65, 66, 76, 86, 96, 70, 71, 72
Offset: 0

Views

Author

Keywords

Comments

a(A009996(n)) = A009996(n). - Reinhard Zumkeller, Oct 31 2007
If we define "sortable primes" as prime numbers that remain prime when their digits are sorted in decreasing order, then all absolute primes (A003459) are sortable primes but not all sortable primes are absolute primes. For example, 113 is both sortable and absolute, and 313 is sortable but not absolute since its digits can be permuted to 133 = 7 * 19. - Alonso del Arte, Oct 05 2013

Examples

			a(19) = 91 because the digits of 19 being 1 and 9, arranged in decreasing order they are 9 and 1.
a(20) = 20 because the digits are already in decreasing order.
		

Crossrefs

Programs

  • Haskell
    import Data.List (sort)
    a004186 = read . reverse . sort . show :: Integer -> Integer
    -- Reinhard Zumkeller, Aug 19 2011
    
  • Maple
    A004186 := proc(n)
        local dgs;
        convert(n,base,10) ;
        dgs := sort(%) ;
        add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ;
    end proc:
    seq(A004186(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
  • Mathematica
    sortDigitsDown[n_] := FromDigits@ Reverse@ Sort@ IntegerDigits@ n; Array[sortDigitsDown, 73, 0] (* Robert G. Wilson v, Aug 19 2011 *)
  • PARI
    reconstruct(m) = {local(r); r=0; for(i=1,matsize(m)[2],r=r*10+m[i]); r}
    A004186(n) = reconstruct(vecsort(digits(n),,4))
    \\ Michael B. Porter, Nov 11 2009
    
  • PARI
    a(n) = fromdigits(vecsort(digits(n), , 4)); \\ Joerg Arndt, Feb 24 2019
    
  • Python
    def a(n): return int("".join(sorted(str(n), reverse=True)))
    print([a(n) for n in range(73)]) # Michael S. Branicky, Feb 21 2021

Formula

n <= a(n) < 10n. - Charles R Greathouse IV, Aug 07 2024

Extensions

More terms from Reinhard Zumkeller, Oct 31 2007

A038573 a(n) = 2^A000120(n) - 1.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 3, 7, 1, 3, 3, 7, 3, 7, 7, 15, 1, 3, 3, 7, 3, 7, 7, 15, 3, 7, 7, 15, 7, 15, 15, 31, 1, 3, 3, 7, 3, 7, 7, 15, 3, 7, 7, 15, 7, 15, 15, 31, 3, 7, 7, 15, 7, 15, 15, 31, 7, 15, 15, 31, 15, 31, 31, 63, 1, 3, 3, 7, 3, 7, 7, 15, 3, 7, 7, 15, 7, 15, 15, 31, 3, 7, 7, 15, 7, 15, 15, 31
Offset: 0

Views

Author

Keywords

Comments

Essentially the same sequence as A001316, which has much more information, and also A159913. - N. J. A. Sloane, Jun 05 2009
Smallest number with same number of 1's in its binary expansion as n.
Fixed point of the morphism 0 -> 01, 1 -> 13, 3 -> 37, ... = k -> k, 2k+1, ... starting from a(0) = 0; 1 -> 01 -> 0113 -> 01131337 -> 011313371337377(15) -> ..., . - Robert G. Wilson v, Jan 24 2006
From Gary W. Adamson, Jun 04 2009: (Start)
As an infinite string, 2^n terms per row starting with "1": (1; 1,3; 1,3,3,7; 1,3,3,7,3,7,7,15; 1,3,3,7,3,7,7,15,3,7,7,15,7,15,15,31;...)
Row sums of that triangle = A027649: (1, 4, 14, 46, 454, ...); where the next row sum = current term of A027649 + next term in finite difference row of A027649, i.e., (1, 3, 10, 32, 100, 308, ...) = A053581. (End)
From Omar E. Pol, Jan 24 2016: (Start)
Partial sums give A267700.
a(n) is also the number of cells turned ON at n-th generation of the cellular automaton of A267700 in a 90-degree sector on the square grid.
a(n) is also the number of Y-toothpicks added at n-th generation of the structure of A267700 in a 120-degree sector on the triangular grid. (End)
Row sums of A090971. - Nikolaos Pantelidis, Nov 23 2022

Examples

			9 = 1001 -> 0011 -> 3, so a(9)=3.
From _Gary W. Adamson_, Jun 04 2009: (Start)
Triangle read by rows:
  1;
  1, 3;
  1, 3, 3, 7;
  1, 3, 3, 7, 3, 7, 7, 15;
  1, 3, 3, 7, 3, 7, 7, 15, 3, 7, 7, 15, 7, 15, 15, 31;
  ...
Row sums: (1, 4, 14, 46, ...) = A027649 = last row terms + new set of terms such that row 3 = (1, 3, 3, 7,) + (3, 7, 7, 15) = 14 + 32 = A027649(2) + A053581(3). (End)
The rows of this triangle converge to A159913. - _N. J. A. Sloane_, Jun 05 2009
G.f. = x + x^2 + 3*x^3 + x^4 + 3*x^5 + 3*x^6 + 7*x^7 + x^8 + 3*x^9 + 3*x^10 + 7*x^11 + ... - _Michael Somos_, Jul 24 2023
		

Crossrefs

This is Guy Steele's sequence GS(3, 6) (see A135416).
Write n in b-ary, sort digits into increasing order: this sequence (b=2), A038574 (b=3), A319652 (b=4), A319653 (b=5), A319654 (b=6), A319655 (b=7), A319656 (b=8), A319657 (b=9), A004185 (b=10).
Column k=0 of A340666.

Programs

  • Haskell
    a038573 0 = 0
    a038573 n = (m + 1) * (a038573 n') + m where (n', m) = divMod n 2
    -- Reinhard Zumkeller, Oct 10 2012, Feb 07 2011
    (Python 3.10+)
    def A038573(n): return (1<Chai Wah Wu, Nov 15 2022
  • Maple
    seq(2^convert(convert(n,base,2),`+`)-1, n=0..100); # Robert Israel, Jan 24 2016
  • Mathematica
    Array[ 2^Count[ IntegerDigits[ #, 2 ], 1 ]-1&, 100 ]
    Nest[ Flatten[ # /. a_Integer -> {a, 2a + 1}] &, {0}, 7] (* Robert G. Wilson v, Jan 24 2006 *)
  • PARI
    {a(n) = 2^subst(Pol(binary(n)), x, 1) - 1};
    
  • PARI
    a(n) = 2^hammingweight(n)-1; \\ Michel Marcus, Jan 24 2016
    

Formula

a(2n) = a(n), a(2n+1) = 2*a(n)+1, a(0) = 0. a(n) = A001316(n)-1 = 2^A000120(n) - 1. - Daniele Parisse
a(n) = number of positive integers k < n such that n XOR k = n-k (cf. A115378). - Paul D. Hanna, Jan 21 2006
a(n) = f(n, 1) with f(x, y) = if x = 0 then y - 1 else f(floor(x/2), y*(1 + x mod 2)). - Reinhard Zumkeller, Nov 21 2009
a(n) = (n mod 2 + 1) * a(floor(n/2)) + n mod 2. - Reinhard Zumkeller, Oct 10 2012
a(n) = Sum_{i=1..n} C(n,i) mod 2. - Wesley Ivan Hurt, Nov 17 2017
G.f.: -1/(1 - x) + Product_{k>=0} (1 + 2*x^(2^k)). - Ilya Gutkovskiy, Aug 20 2019
G.f. A(x) = x + x^2*A(x) + (1 + 2*x)*(1 - x^2)*A(x^2). - Michael Somos, Jul 24 2023

Extensions

More terms from Erich Friedman
New definition from N. J. A. Sloane, Mar 01 2008
Showing 1-10 of 42 results. Next