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 10 results.

A254524 n is the a(n)-th positive integer having its digitsum.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 8, 8, 8, 7, 6, 5, 4, 3, 2, 1, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 5
Offset: 1

Views

Author

David A. Corneth, Jan 31 2015

Keywords

Comments

a(A051885(n)) = 1. - Reinhard Zumkeller, Oct 09 2015
Ordinal transform of A007953. - Antti Karttunen, May 20 2017

Examples

			35 is the 4th positive integer having digitsum 8 (the others before are 8, 17 and 26) so a(35) = 4.
		

Crossrefs

Cf. A286478 (analogous sequence for factorial base).

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a254524 n = a254524_list !! (n-1)
    a254524_list = f 1 empty where
       f x m = y : f (x + 1) (insert q (y + 1) m) where
               y = findWithDefault 1 q m; q = a007953 x
    -- Reinhard Zumkeller, Oct 09 2015
  • Mathematica
    c[n_, k_] := If[n >= k, Binomial[n, k], 0]; b[s_, q_, n_] := (s1 = q; If[s <= q*(n - 1), s1 = s + q; Sum[(-1)^i*c[q, i]*c[s1 - 1 - n*i, q - 1], {i, 0, q - 1}], 0]); a[n_] := (r = 1; v = IntegerDigits[n]; l = v[[-1]]; For[i = Length[v] - 1, i >= 1, i--, For[j = 1, j <= v[[i]], j++, r += b[l + j, Length[v] - i, 10]]; l += v[[i]]]; r); Table[a[n], {n, 1, 110}] (* Jean-François Alcover, Nov 14 2016, adapted from PARI *)
    With[{nn=400},#[[3]]&/@Sort[Flatten[Table[Flatten[#,1]&/@MapIndexed[ List,Select[ Table[{n,Total[IntegerDigits[n]]},{n,nn}],#[[2]]==k&]],{k,nn}],1]]](* Harvey P. Dale, Mar 29 2020 *)
  • PARI
    \\This algorithm needs a modified binomial.
    C(n, k)=if(n>=k, binomial(n, k), 0)
    \\ways to roll s-q with q dice having sides 0 through n - 1.
    b(s, q, n)=if(s<=q*(n-1), s+=q; sum(i=0, q-1, (-1)^i*C(q, i)*C(s-1-n*i, q-1)), 0)
    \\main algorithm
    a(n)={r = 1; v=digits(n); l=v[#v]; forstep(i = #v-1, 1, -1, for(j=1,v[i], r+=b(l+j, #v-i,10)); l+=v[i]);r}
    

A068076 Number of positive integers < n with the same number of 1's in their binary expansions as n.

Original entry on oeis.org

0, 1, 0, 2, 1, 2, 0, 3, 3, 4, 1, 5, 2, 3, 0, 4, 6, 7, 4, 8, 5, 6, 1, 9, 7, 8, 2, 9, 3, 4, 0, 5, 10, 11, 10, 12, 11, 12, 5, 13, 13, 14, 6, 15, 7, 8, 1, 14, 16, 17, 9, 18, 10, 11, 2, 19, 12, 13, 3, 14, 4, 5, 0, 6, 15, 16, 20, 17, 21, 22, 15, 18, 23, 24, 16, 25, 17, 18, 6, 19, 26, 27, 19
Offset: 1

Views

Author

Dean Hickerson, Feb 16 2002

Keywords

Comments

From Rémy Sigrist, Dec 23 2018: (Start)
This sequence is related to the combinatorial number system:
- if n = Sum_{k=1..h} 2^c_k with 0 <= c_1 < c_2 < ... < c_h,
- then a(n) = Sum_{k=1..h} binomial(c_k, k) (with binomial(n, r) = 0 if n < r).
(End)

Examples

			The binary expansion of 22 (10110) has 3 1's, as do those of the 6 smaller numbers 7, 11, 13, 14, 19 and 21, so a(22)=6.
		

Crossrefs

One less than A263017.
Cf. A067587, also A000120 for numerous references.

Programs

  • Mathematica
    w[n_] := Plus@@IntegerDigits[n, 2]; a[n_] := Plus@@MapThread[Binomial, {Flatten[Position[Reverse[IntegerDigits[n, 2]], 1]]-1, Range[w[n]]}]
  • PARI
    a(n)=my(k=hammingweight(n));sum(i=1,n-1,hammingweight(i)==k) \\ Charles R Greathouse IV, Sep 24 2012
    
  • PARI
    a(n) = my (v=0, k=0); for (c=0, oo, if (n==0, return (v), n%2, k++; if (c>=k, v+=c!/k!/(c-k)!)); n\=2) \\ Rémy Sigrist, Dec 23 2018
    
  • Python
    def a(n):
        x=bin(n)[2:].count("1")
        return sum(1 for i in range(n) if bin(i)[2:].count("1")==x) # Indranil Ghosh, May 24 2017
    
  • Python
    from math import comb
    def A068076(n):
        c, k = 0, 1
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                c += comb(i,k)
                k += 1
        return c # Chai Wah Wu, Mar 01 2023

Formula

a(n) = A263017(n) - 1. - Antti Karttunen, May 22 2017

Extensions

Edited by John W. Layman, Feb 20 2002

A067587 Inverse of A066884 considered as a permutation of the positive integers.

Original entry on oeis.org

1, 3, 2, 6, 5, 9, 4, 10, 14, 20, 8, 27, 13, 19, 7, 15, 35, 44, 26, 54, 34, 43, 12, 65, 53, 64, 18, 76, 25, 33, 11, 21, 77, 90, 89, 104, 103, 118, 42, 119, 134, 151, 52, 169, 63, 75, 17, 135, 188, 208, 88, 229, 102, 117, 24, 251, 133, 150, 32, 168, 41, 51, 16, 28, 152
Offset: 1

Views

Author

Jared Ricks (jaredricks(AT)yahoo.com), Jan 31 2002

Keywords

Crossrefs

Programs

  • Mathematica
    w[n_] := Plus@@IntegerDigits[n, 2]; p[n_] := Plus@@MapThread[Binomial, {Flatten[Position[Reverse[IntegerDigits[n, 2]], 1]]-1, Range[w[n]]}]; a[n_] := Binomial[w[n]+p[n], 2]+p[n]+1
  • PARI
    a(n)=my(w=hammingweight(n), p=sum(i=1, n-1, hammingweight(i)==w)); binomial(w+p, 2) + p + 1 \\ Jianing Song, Aug 06 2022
    
  • Perl
    foreach(1..10_000){$i=eval join "+", split //, sprintf "%b", $; $j=$r[$i]++; print "$ ",$j+1+($i+$j)*($i+$j-1)/2,"\n"} # Ivan Neretin, Mar 02 2016
    
  • Python
    from math import comb
    def A067587(n):
        c, k = 0, 0
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                k += 1
                c += comb(i,k)
        return comb(n.bit_count()+c,2)+c+1 # Chai Wah Wu, Mar 02 2023

Formula

Let w(n) = A000120(n) be the 'weight' of n; i.e. the number of 1's in the binary expansion of n. Let p(n) = A068076(n) be the number of positive integers < n with the same weight as n. Then a(n) = binomial(w(n)+p(n),2) + p(n) + 1.

Extensions

Edited by Dean Hickerson, Feb 16 2002
Offset changed to 1 by Ivan Neretin, Mar 02 2016

A263109 n is the a(n)-th positive integer having its digitsum in base-12 representation.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Oct 09 2015

Keywords

Comments

Ordinal transform of A053832. - Alois P. Heinz, Dec 23 2018

Crossrefs

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a263109 n = a263109_list !! (n-1)
    a263109_list = f 1 empty where
       f x m = y : f (x + 1) (insert q (y + 1) m) where
               y = findWithDefault 1 q m; q = a053832 x
  • Mathematica
    b[_] = 1;
    a[n_] := a[n] = With[{t = Total[IntegerDigits[n, 12]]}, b[t]++];
    Array[a, 100] (* Jean-François Alcover, Dec 18 2021 *)

A263110 n is the a(n)-th positive integer having its digitsum in base-16 representation.

Original entry on oeis.org

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, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 6, 6, 6, 6, 6, 6, 6
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 09 2015

Keywords

Comments

Ordinal transform of A053836. - Alois P. Heinz, Dec 23 2018

Crossrefs

Programs

  • Haskell
    import Data.IntMap (empty, findWithDefault, insert)
    a263110 n = a263110_list !! (n-1)
    a263110_list = f 1 empty where
       f x m = y : f (x + 1) (insert q (y + 1) m) where
               y = findWithDefault 1 q m; q = a053836 x

A286552 Ordinal transform of A286622, or equally, of A278222.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, May 21 2017

Keywords

Crossrefs

A286558 Ordinal transform of A005811.

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 3, 3, 4, 2, 1, 3, 5, 4, 6, 4, 7, 5, 2, 6, 3, 1, 4, 7, 8, 8, 5, 9, 9, 10, 10, 5, 11, 11, 6, 12, 7, 2, 8, 13, 9, 3, 1, 4, 10, 5, 11, 14, 12, 15, 12, 16, 13, 6, 14, 17, 13, 18, 15, 19, 14, 20, 15, 6, 16, 21, 16, 22, 17, 7, 18, 23, 19, 8, 2, 9, 20, 10, 21, 24, 22, 11, 3, 12, 4, 1, 5, 13, 23, 14, 6, 15, 24, 16, 25, 25, 17, 26, 26, 27, 27, 17, 28, 28
Offset: 0

Views

Author

Antti Karttunen, May 21 2017

Keywords

Crossrefs

Cf. A005811.
Cf. A263017, A254524, A286478, A286554 for similar sequences.

A356419 Inverse of A067576 considered as a permutation of the positive integers.

Original entry on oeis.org

1, 2, 3, 4, 5, 8, 6, 7, 12, 17, 9, 23, 13, 18, 10, 11, 30, 38, 24, 47, 31, 39, 14, 57, 48, 58, 19, 69, 25, 32, 15, 16, 68, 80, 81, 93, 94, 108, 40, 107, 123, 139, 49, 156, 59, 70, 20, 122, 174, 193, 82, 213, 95, 109, 26, 234, 124, 140, 33, 157, 41, 50, 21, 22, 138, 155, 256
Offset: 1

Views

Author

Jianing Song, Aug 06 2022

Keywords

Examples

			A067576(12) = 9, so a(9) = 12.
		

Crossrefs

Programs

  • PARI
    a(n)=my(w=hammingweight(n), p=sum(i=1, n-1, hammingweight(i)==w)); binomial(w+p+1, 2) - p
    
  • Python
    from math import comb
    def A356419(n):
        c, k = 0, 0
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                k += 1
                c += comb(i,k)
        return comb(n.bit_count()+c+1,2)-c # Chai Wah Wu, Mar 02 2023

Formula

Let w(n) = A000120(n) be the Hamming weight of n, p(n) = A068076(n), then a(n) = binomial(w(n)+p(n)+1, 2) - p(n).

A263018 If n is the i-th positive integer with binary weight j, then a(n) is the j-th positive integer with binary weight i.

Original entry on oeis.org

1, 3, 2, 7, 5, 11, 4, 15, 23, 47, 6, 95, 13, 27, 8, 31, 191, 383, 55, 767, 111, 223, 9, 1535, 447, 895, 14, 1791, 29, 59, 16, 63, 3071, 6143, 3583, 12287, 7167, 14335, 119, 24575, 28671, 57343, 239, 114687, 479, 959, 10, 49151, 229375, 458751, 1919, 917503
Offset: 1

Views

Author

Paul Tek, Oct 07 2015

Keywords

Comments

Binary weight is given by A000120.
This is a self-inverse permutation of the natural numbers.
The positive terms in the sequence A036563 give the fixed points.
A000120(n) = A263017(a(n)) for any n>0.
A263017(n) = A000120(a(n)) for any n>0.
a(2^(n+1)-1) = 2^n for any n>0.
a(2^n) = 2^(n+1)-1 for any n>0.

Crossrefs

Programs

  • PARI
    a(n) = {j = hammingweight(n); v = vector(n, k, hammingweight(k)); i = #select(x->x==j, v); nb = 0; k = 0; while(nb != j, k++; if (hammingweight(k) == i, nb++)); k;} \\ Michel Marcus, Oct 16 2015

A361079 Number of integers in [n .. 2n-1] having the same binary weight as n.

Original entry on oeis.org

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

Views

Author

Alois P. Heinz, Mar 01 2023

Keywords

Comments

Or number of steps it takes to double n, where each step goes to the next larger integer with the same binary weight.

Examples

			a(9) = 4: 9 -> 10 -> 12 -> 17 -> 18 or in binary: 1001_2 -> 1010_2 -> 1100_2 -> 10001_2 -> 10010_2.
		

Crossrefs

Programs

  • Maple
    b:= proc(n) option remember; uses Bits; local c, l, k;
          c, l:= 0, [Split(n)[], 0];
          for k while l[k]<>1 or l[k+1]<>0 do c:=c+l[k] od;
          Join([1$c, 0$k-c, 1, l[k+2..-1][]])
        end:
    a:= proc(n) option remember; local i, m, t; m, t:=n, 2*n;
          for i from 0 while m<>t do m:= b(m) od; i
        end:
    seq(a(n), n=0..100);
  • Mathematica
    f[n_] := f[n] = DigitCount[n, 2, 1]; a[n_] := Count[ Array[f, n, n], f[n]]; Array[a, 75, 0] (* Robert G. Wilson v, Mar 15 2023 *)
  • PARI
    a(n) = my(w=hammingweight(n)); sum(k=n, 2*n-1, hammingweight(k) == w); \\ Michel Marcus, Mar 16 2023
  • Python
    from math import comb
    def A361079(n):
        c, k = 0, 1
        for i,j in enumerate(bin(n)[-1:1:-1]):
            if j == '1':
                c += comb(i+1,k)-comb(i,k)
                k += 1
        return c # Chai Wah Wu, Mar 01 2023
    

Formula

a(n) = |{ k in [n, 2n-1] : A000120(k) = A000120(n) }|.
((x-> A057168(x))^a(n))(n) = 2*n.
a(n) = A068076(2n) - A068076(n) = A263017(2n) - A263017(n).
a(n) = 1 <=> n in { A000079 }.
Showing 1-10 of 10 results.