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.

A014312 Numbers with exactly 4 ones in binary expansion.

Original entry on oeis.org

15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197
Offset: 1

Views

Author

Al Black (gblack(AT)nol.net)

Keywords

Crossrefs

Cf. A090706.
Cf. A000079, A018900, A014311, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 2, ..., 9), A057168.

Programs

  • Mathematica
    Select[ Range[ 180 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==4)& ] (* Olivier Gérard *)
  • PARI
    for(n=0,10^3,if(hammingweight(n)==4,print1(n,", "))); \\ Joerg Arndt, Mar 04 2014
    
  • PARI
    print1(t=15); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Perl
    $N = 4;
    my $vector = 2 ** $N - 1;  # first key (15)
    for (1..100) {
      print "$vector, ";
      my ($v, $d) = ($vector, 0);
      until ($v & 1 or !$v) { $d = ($d << 1)|1; $v >>= 1 }
      $vector += $d + 1 + (($v ^ ($v + 1)) >> 2);  # next key
    } # Ruud H.G. van Tol, Mar 02 2014
    
  • Python
    A014312_list = [2**a+2**b+2**c+2**d for a in range(3,6) for b in range(2,a) for c in range(1,b) for d in range(c)] # Chai Wah Wu, Jan 24 2021
    
  • Python
    from itertools import islice
    def A014312_gen(): # generator of terms
        yield (n:=15)
        while True: yield (n:=n^((a:=-n&n+1)|(a>>1)) if n&1 else ((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b)
    A014312_list = list(islice(A014312_gen(),20)) # Chai Wah Wu, Mar 10 2025
    
  • Rust
    pub const fn next_choice(value: usize) -> usize {
      // Passing a term will return the next number in the sequence
      let zeros = value.trailing_zeros();
      let ones = (value >> zeros).trailing_ones();
      value + (1 << zeros) + (1 << (ones - 1)) - 1
    } // Andrew Bennett, Jan 07 2022

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
a(n) = 2^A194882(n-1) + 2^A194883(n-1) + 2^A194884(n-1) + 2^A127324(n-1). - Ridouane Oudra, Sep 06 2020
Sum_{n>=1} 1/a(n) = 1.399770961748474333075618147113153558623203796657745865012742162098738541849... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

Extensions

Extension by Olivier Gérard

A091708 Number of primes less than 10^n having at least one digit 7.

Original entry on oeis.org

1, 9, 68, 549, 4819, 43506, 397756, 3681943, 34344296, 322199867, 3036544958, 28722439343, 272501681533, 2591959274190
Offset: 1

Views

Author

Enoch Haga, Jan 30 2004

Keywords

Examples

			a(1) = 1 because of the 4 primes less than 10^1, 1 has at least one digit 7.
		

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; c = 0; p = 1; Do[ While[ p = NextPrim[p]; p < 10^n, If[ Position[ IntegerDigits[p], 7] != {}, c++ ]]; Print[c]; p--, {n, 1, 8}] (* Robert G. Wilson v, Feb 02 2004 *)
    Table[Count[Prime[Range[PrimePi[10^n]]],?(DigitCount[#,10,7]>0&)],{n,12}] (* _Harvey P. Dale, Mar 03 2013 *)

Extensions

Edited and extended by Robert G. Wilson v, Feb 02 2004
3 more terms from Ryan Propper, Aug 21 2005
a(13) from Robert Price, Nov 11 2013
a(14) from Giovanni Resta, Jul 21 2015

A091709 Number of primes less than 10^n having at least one digit 8.

Original entry on oeis.org

0, 2, 27, 314, 3217, 31699, 308774, 2987107, 28824402, 277779084, 2674980022, 25752370493, 247919235555, 2387154761520
Offset: 1

Views

Author

Enoch Haga, Jan 30 2004

Keywords

Examples

			a(2) = 2 because of the 25 primes less than 10^2, 2 have at least one digit 8.
		

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; c = 0; p = 1; Do[ While[ p = NextPrim[p]; p < 10^n, If[ Position[ IntegerDigits[p], 8] != {}, c++ ]]; Print[c]; p--, {n, 1, 8}] (* Robert G. Wilson v, Feb 02 2004 *)
  • Python
    from sympy import sieve # use slower primerange for larger terms
    def a(n): return sum('8' in str(p) for p in sieve.primerange(2, 10**n))
    print([a(n) for n in range(1, 8)]) # Michael S. Branicky, Apr 23 2021

Extensions

Edited and extended by Robert G. Wilson v, Feb 02 2004
3 more terms from Ryan Propper, Aug 22 2005
a(13) from Robert Price, Nov 11 2013
a(14) from Giovanni Resta, Jul 21 2015

A091710 Number of primes less than 10^n having at least one digit 9.

Original entry on oeis.org

0, 6, 60, 542, 4826, 43359, 397093, 3677641, 34316162, 321993007, 3035059323, 28710966351, 272413818120, 2591276923548
Offset: 1

Views

Author

Enoch Haga, Jan 30 2004

Keywords

Examples

			a(2) = 6 because of the 25 primes less than 10^2, 6 have at least one digit 9.
		

Crossrefs

Programs

  • Mathematica
    NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; c = 0; p = 1; Do[ While[ p = NextPrim[p]; p < 10^n, If[ Position[ IntegerDigits[p], 9] != {}, c++ ]]; Print[c]; p--, {n, 1, 8}] (* Robert G. Wilson v, Feb 02 2004 *)

Extensions

Edited and extended by Robert G. Wilson v, Feb 02 2004
3 more terms from Ryan Propper, Aug 22 2005
a(13) from Robert Price, Nov 11 2013
a(14) from Giovanni Resta, Jul 21 2015

A187786 Table read by rows, where n-th row contains all numbers having in binary representation as many zeros and ones as n.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Jan 06 2013

Keywords

Comments

For k = 0..A090706(n)-1: A023416(T(n,k))=A023416(n); A000120(T(n,k))=A000120(n); A053644(n)<=T(n,k)<=A003817(n);
T(n,k) = n for some k;
A187769 contains all rows without repetitions.

Examples

			.  n  n-th row              binary                          row length
. --  --------------------- ------------------------------- ----------
.  0  {0}                   {0}                                      1
.  1  {1}                   {1}                                      1
.  2  {2}                   {10}                                     1
.  3  {3}                   {11}                                     1
.  4  {4}                   {100}                                    1
.  5  {5,6}                 {101,110}                                2
.  6  {5,6}                 {101,110}                                2
.  7  {7}                   {111}                                    1
.  8  {8}                   {1000}                                   1
.  9  {9,10,12}             {1001,1010,1100}                         3
. 10  {9,10,12}             {1001,1010,1100}                         3
. 11  {11,13,14}            {1011,1101,1110}                         3
. 12  {9,10,12}             {1001,1010,1100}                         3
. 13  {11,13,14}            {1011,1101,1110}                         3
. 14  {11,13,14}            {1011,1101,1110}                         3
. 15  {15}                  {1111}                                   1
. 16  {16}                  {10000}                                  1
. 17  {17,18,20,24}         {10001,10010,10100,11000}                4
. 18  {17,18,20,24}         {10001,10010,10100,11000}                4
. 19  {19,21,22,25,26,28}   {10011,10101,10110,11001,11010,11100}    6
. 20  {17,18,20,24}         {10001,10010,10100,11000}                4 .
		

Programs

  • Haskell
    import List (find)
    import Maybe (fromJust)
    a187786 n k = a187786_tabf !! n !! k
    a187786_row n = fromJust $ find (elem n) a187769_tabf
    a187786_tabf = map a187786_row [0..]

A361477 a(n) is the number of integers whose binary expansions have the same multiset of run-lengths as that of n.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 1, 3, 1, 3, 2, 1, 2, 3, 4, 3, 4, 1, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 6, 6, 5, 6, 6, 4, 5, 1, 5, 6, 5, 4, 3, 2, 6, 6, 1, 6, 5, 6, 6, 1, 6, 4, 6, 2, 3, 2, 1, 2, 3, 4, 6, 12, 5, 12, 3, 12, 10, 6, 10, 4, 10, 12, 6, 4, 5, 6, 10
Offset: 0

Views

Author

Rémy Sigrist, Mar 13 2023

Keywords

Comments

This sequence has similarities with A090706; here we consider multisets of run-lengths, there multisets of digits in binary expansions.

Examples

			For n = 18:
- the binary expansion of 18 is "10010",
- the corresponding multiset of run-lengths is m = (1, 2, 1, 1),
- m has 4 terms: 3 times "1" and once "2",
- so a(18) = 4! / (3! * 1!) = 4.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); my (s=Set(r), f=vector(#s)); for (k=1, #r, f[setsearch(s, r[k])]++); (#r)! / prod(k=1, #f, f[k]!) }
    
  • Python
    from math import factorial, prod
    from itertools import groupby
    from collections import Counter
    def A361477(n): return factorial(len(c:=[len(list(g)) for k, g in groupby(bin(n)[2:])]))//prod(map(factorial,Counter(c).values())) # Chai Wah Wu, Mar 16 2023

Formula

a(n) = 1 iff n = 0 or n belongs to A140690.

A378959 Sum, in base 10, of the permutations of the digits of n, written in base 2.

Original entry on oeis.org

0, 1, 3, 3, 7, 14, 14, 7, 15, 45, 45, 45, 45, 45, 45, 15, 31, 124, 124, 186, 124, 186, 186, 124, 124, 186, 186, 124, 186, 124, 124, 31, 63, 315, 315, 630, 315, 630, 630, 630, 315, 630, 630, 630, 630, 630, 630, 315, 315, 630, 630, 630, 630, 630, 630, 315, 630
Offset: 0

Views

Author

Paolo P. Lava, Dec 12 2024

Keywords

Comments

Fixed points are in A000225.

Examples

			a(5) = 14 because 5 in base 2 is 101 and the permutations of the digits are 101, 110, 011 that correspond to 5, 6, 3 and 5 + 6 + 3 = 14.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local k, l;
          l:= convert(n, base, 2); k:= nops(l);
          binomial(k-1, add(i, i=l)-1)*(2^k-1)
        end:
    seq(a(n), n=0..56);  # Alois P. Heinz, Dec 12 2024
  • Mathematica
    A378959[n_] := (2^# - 1)*Binomial[# - 1, DigitCount[n, 2, 0]] & [BitLength[n]];
    Array[A378959, 100, 0] (* Paolo Xausa, Jan 29 2025 *)

Formula

a(n) = A003817(n) * A090706(n). - Alois P. Heinz, Dec 12 2024
Showing 1-7 of 7 results.