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 11-20 of 77 results. Next

A059268 Concatenate subsequences [2^0, 2^1, ..., 2^n] for n = 0, 1, 2, ...

Original entry on oeis.org

1, 1, 2, 1, 2, 4, 1, 2, 4, 8, 1, 2, 4, 8, 16, 1, 2, 4, 8, 16, 32, 1, 2, 4, 8, 16, 32, 64, 1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128, 256, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048
Offset: 0

Views

Author

N. J. A. Sloane, Jan 23 2001

Keywords

Comments

Triangular array T(n,k) read by rows, where T(n,k) = i!*j! times coefficient of x^n*y^k in exp(x+2y).
T(n,k) is the number of subsets of {0,1,...,n} whose largest element is k. To see this, let A be any subset of the 2^k subsets of {0,1,...,k-1}. Then there are 2^k subsets of the form (A U {k}). See example below. - Dennis P. Walsh, Nov 27 2011
Sequence B is called a reluctant sequence of sequence A, if B is triangle array read by rows: row number k coincides with first k elements. A059268 is reluctant sequence of sequence A000079. - Boris Putievskiy, Dec 17 2012

Examples

			T(4,3)=8 since there are 8 subsets of {0,1,2,3,4} whose largest element is 3, namely, {3}, {0,3}, {1,3}, {2,3}, {0,1,3}, {0,2,3}, {1,2,3}, and {0,1,2,3}.
Triangle starts:
  1;
  1, 2;
  1, 2, 4;
  1, 2, 4, 8;
  1, 2, 4, 8, 16;
  1, 2, 4, 8, 16, 32;
  ...
		

Crossrefs

Cf. A140531.
Cf. A000079.
Cf. A131816.
Row sums give A126646.

Programs

  • Haskell
    a059268 n k = a059268_tabl !! n !! k
    a059268_row n = a059268_tabl !! n
    a059268_tabl = iterate (scanl (+) 1) [1]
    -- Reinhard Zumkeller, Apr 18 2013, Jul 05 2012
    
  • Maple
    seq(seq(2^k,k=0..n),n=0..10);
  • Mathematica
    Table[2^k, {n, 0, 11}, {k, 0, n}] // Flatten (* Jean-François Alcover, Jun 10 2013 *)
  • Python
    from math import isqrt
    def A059268(n):
        a = (m:=isqrt(k:=n+1<<1))-(k<=m*(m+1))
        return 1<>1) # Chai Wah Wu, Feb 24 2025

Formula

E.g.f.: exp(x+2*y) (T coordinates).
a(n) = A018900(n+1) - A140513(n). - Reinhard Zumkeller, Jun 24 2009
T(n,k) = A173786(n-1,k-1) - A173787(n-1,k-1), 0Reinhard Zumkeller, Feb 28 2010
T(n,k) = 2^k. - Reinhard Zumkeller, Jan 29 2010
As a linear array, the sequence is a(n) = 2^(n-1-t*(t+1)/2), where t = floor((-1+sqrt(8*n-7))/2), n>=1. - Boris Putievskiy, Dec 17 2012
As a linear array, the sequence is a(n) = 2^(n-1-t*(t+1)/2), where t = floor(sqrt(2*n)-1/2), n>=1. - Zhining Yang, Jun 09 2017

Extensions

Formula corrected by Reinhard Zumkeller, Feb 23 2010

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

A014313 Numbers with exactly 5 ones in binary expansion.

Original entry on oeis.org

31, 47, 55, 59, 61, 62, 79, 87, 91, 93, 94, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124, 143, 151, 155, 157, 158, 167, 171, 173, 174, 179, 181, 182, 185, 186, 188, 199, 203, 205, 206, 211, 213, 214, 217, 218, 220, 227, 229, 230, 233, 234, 236, 241, 242
Offset: 1

Views

Author

Al Black (gblack(AT)nol.net)

Keywords

Comments

Appears to give all n such that 4096 is the highest power of 2 dividing A005148(n). - Benoit Cloitre, Jun 22 2002

Crossrefs

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

Programs

  • Haskell
    a014313 = f . a038447 where
       f x = if x == 0 then 0 else 2 * f x' + b  where (x', b) = divMod x 10
    -- Reinhard Zumkeller, Jan 06 2015
    
  • Mathematica
    Select[ Range[31, 240], Total[IntegerDigits[#, 2]] == 5&]
  • PARI
    sum_of_bits(n) = if(n<1, 0, sum_of_bits(floor(n/2))+n%2)
    isA014313(n) = (sum_of_bits(n) == 5); \\ Michael B. Porter, Oct 21 2009
    
  • PARI
    is(n)=hammingweight(n)==5 \\ Charles R Greathouse IV, Nov 17 2013
    
  • PARI
    print1(t=2^5-1); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Python
    from itertools import islice
    def A014313_gen(): # generator of terms
        yield (n:=31)
        while True: yield (n:=((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b)
    A014313_list = list(islice(A014313_gen(),30)) # Chai Wah Wu, Mar 06 2025

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
A038447(n) = A007088(a(n)). - Reinhard Zumkeller, Jan 06 2015
Sum_{n>=1} 1/a(n) = 1.390704528210321982529622080740025763242354253694629591331835888395977392151... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

Extensions

Extension and program by Olivier Gérard

A023689 Numbers with exactly 7 ones in binary expansion.

Original entry on oeis.org

127, 191, 223, 239, 247, 251, 253, 254, 319, 351, 367, 375, 379, 381, 382, 415, 431, 439, 443, 445, 446, 463, 471, 475, 477, 478, 487, 491, 493, 494, 499, 501, 502, 505, 506, 508, 575, 607, 623, 631, 635, 637, 638, 671, 687
Offset: 1

Views

Author

Keywords

Crossrefs

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

Programs

  • Mathematica
    Select[ Range[ 127, 704 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==7)& ]
  • PARI
    is_A023689(n)=hammingweight(n)==7 \\ M. F. Hasler, Aug 27 2014
    
  • PARI
    print1(t=2^7-1); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Python
    from itertools import islice
    def A023689_gen(): # generator of terms
        yield (n:=127)
        while True: yield (n:=((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b)
    A023689_list =  list(islice(A023689_gen(),30)) # Chai Wah Wu, Mar 06 2025

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
Sum_{n>=1} 1/a(n) = 1.386779022721502147026318489565477811900220906277367947393004721391094590038... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

A023690 Numbers with exactly 8 ones in binary expansion.

Original entry on oeis.org

255, 383, 447, 479, 495, 503, 507, 509, 510, 639, 703, 735, 751, 759, 763, 765, 766, 831, 863, 879, 887, 891, 893, 894, 927, 943, 951, 955, 957, 958, 975, 983, 987, 989, 990, 999, 1003, 1005, 1006, 1011, 1013, 1014, 1017
Offset: 1

Views

Author

Keywords

Crossrefs

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

Programs

  • Mathematica
    Select[ Range[ 255, 1024 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==8)& ]
  • PARI
    is_A023690(n)=hammingweight(n)==8 \\ M. F. Hasler, Aug 27 2014
    
  • PARI
    print1(t=2^8-1); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Python
    from itertools import count, islice
    def A023690_gen(): # generator of terms
        n = 255
        while True:
            yield n
            n = ((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b
    A023690_list = list(islice(A023690_gen(),30)) # Chai Wah Wu, Mar 06 2025

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
Sum_{n>=1} 1/a(n) = 1.386455689748809038407077281583569975813437283445124123432573411446506561062... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

A023688 Numbers with exactly 6 ones in binary expansion.

Original entry on oeis.org

63, 95, 111, 119, 123, 125, 126, 159, 175, 183, 187, 189, 190, 207, 215, 219, 221, 222, 231, 235, 237, 238, 243, 245, 246, 249, 250, 252, 287, 303, 311, 315, 317, 318, 335, 343, 347, 349, 350, 359, 363, 365, 366, 371, 373
Offset: 1

Views

Author

Keywords

Comments

Sequence appears to include all numbers m such that 8^5 is the highest power of 2 dividing A005148(m). General conjecture: numbers k such that 8^j is the highest power of 2 dividing A005148(k) is the same sequence as numbers having exactly (j+1) 1's in their binary representation. - Benoit Cloitre, Jun 22 2002

Crossrefs

Cf. A000079, A018900, A014311, A014312, A014313, A023689, A023690, A023691 (Hamming weight = 1..9).

Programs

  • Mathematica
    Select[ Range[ 63, 380 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==6)& ]
  • PARI
    is_A023688(n)=hammingweight(n)==6 \\ M. F. Hasler, Aug 27 2014
    
  • PARI
    print1(t=2^6-1); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Python
    from itertools import islice
    def A023688_gen(): # generator of terms
        yield (n:=63)
        while True: yield (n:=((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b)
    A023688_list = list(islice(A023688_gen(),30)) # Chai Wah Wu, Mar 06 2025

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
Sum_{n>=1} 1/a(n) = 1.387753111935705074750004158584017188750706394077047633137401652680870607884... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

A023691 Numbers with exactly 9 ones in binary expansion.

Original entry on oeis.org

511, 767, 895, 959, 991, 1007, 1015, 1019, 1021, 1022, 1279, 1407, 1471, 1503, 1519, 1527, 1531, 1533, 1534, 1663, 1727, 1759, 1775, 1783, 1787, 1789, 1790, 1855, 1887, 1903, 1911, 1915, 1917, 1918, 1951, 1967, 1975
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A000079, A018900, A014311, A014312, A014313, A023688, A023689, A023690 (Hamming weight = 1, 2, ..., 8), A057168.

Programs

  • Mathematica
    Select[ Range[ 511, 2048 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==9)& ]
  • PARI
    is_A023691(n)=hammingweight(n)==9 \\ M. F. Hasler, Aug 27 2014
    
  • PARI
    print1(t=2^9-1); for(i=2, 50, print1(", "t=A057168(t))) \\ M. F. Hasler, Aug 27 2014
    
  • Python
    from itertools import islice
    def A023691_gen(): # generator of terms
        yield (n:=511)
        while True: yield (n:=((n&~(b:=n+(a:=n&-n)))>>a.bit_length())^b)
    A023691_list = list(islice(A023691_gen(),30)) # Chai Wah Wu, Mar 06 2025

Formula

a(n+1) = A057168(a(n)). - M. F. Hasler, Aug 27 2014
Sum_{n>=1} 1/a(n) = 1.386348105265697723853732153017686670695581836109569165990080192653647019078... (calculated using Baillie's irwinSums.m, see Links). - Amiram Eldar, Feb 14 2022

A187813 Numbers n whose base-b digit sum is not b for all bases b >= 2.

Original entry on oeis.org

0, 1, 2, 4, 8, 14, 30, 32, 38, 42, 44, 54, 60, 62, 74, 84, 90, 98, 102, 104, 108, 110, 114, 128, 138, 140, 150, 152, 158, 164, 168, 174, 180, 182, 194, 198, 200, 212, 224, 228, 230, 234, 240, 242, 252, 270, 278, 282, 284, 294, 308, 312, 314, 318, 332, 338, 348
Offset: 1

Views

Author

Tom Edgar, Aug 30 2013

Keywords

Comments

Except for 1, every number is even.
No number ends in 6.
Numbers neither in A018900 nor in A226636 nor in A226969 nor in A227062 nor in A227080 nor ... . - R. J. Mathar, Sep 02 2013
From Hieronymus Fischer, Mar 27 2014, May 09 2014: (Start)
A079696 and this sequence have no terms in common.
Numbers which satisfy m == 1 (mod j) and m > j^2 for any j > 1 are not terms.
Example 1: m = 10^k, k>1, is not a term since 10^k == 1 (mod 9) and 10^k > 9^2.
Example 2: m = 1 + 3k, k > 3, is not a term, since m > 3(1+3) > 3^2.
This is the complement of the disjunction of A079696 with A239708.
Disregarding the first 3 terms, these are the numbers which are in A008864 but not in A239708. This leads to the following characterization: A number m > 2 is a term, i.e., satisfies digitalSum_b(m) <> b for all b > 1, if and only m is a prime number + 1 and m is not the sum of two distinct powers of 2.
a(6) is the only term such that a(n) = Prime(n) + 1. For n < 6, we have a(n) < Prime(n) + 1, and for n > 6, we have a(n) > Prime(n) + 1.
(End)

Examples

			8 has binary expansion (1,0,0,0) whose digit sum 1 is not 2,
ternary expansion (2,2) whose digit sum 4 is not 3,
quaternary expansion (2,0) whose digit sum 2 is not 4,
5-ary expansion (1,3) whose digit sum 4 is not 5,
6-ary expansion (1,2) whose digit sum 3 is not 6,
7-ary expansion (1,1) whose digit sum 2 is not 7,
8-ary expansion (1,0) whose digit sum 1 is not 8,
and b-ary expansion (8) when b>8 whose digit sum is 8 not b. Therefore, 8 is in the sequence.
3 has binary expansion (1,1) whose digit sum is 2, so 3 is not in the sequence.
From _Hieronymus Fischer_, Apr 10 2014: (Start)
a(10) = 42 (the 13th prime + 1)
a(100) = 618 (the 113th prime + 1)
a(1000) = 8172 (the 1026th prime + 1)
a(10^4) = 105254 (the 10042nd prime + 1)
a(10^5) = 1300464 (the 100056th prime + 1)
a(10^6) = 15486872 (the 1000063th prime + 1)
a(10^7) = 179425944 (the 10000071st prime + 1)
a(10^8) = 2038076324 (the 10^8 +84th prime + 1)
a(10^9) = 22801765334 (the 10^9 +92nd prime + 1)
a(10^10) = 252097803264 (the 10^10 +102nd prime + 1)
[calculation for large numbers processed with Smalltalk method A187813With: estimate; see Prog section]
(End)
		

Crossrefs

Programs

  • Mathematica
    Q@n_:=AllTrue[Table[{b,Plus@@IntegerDigits[n,b]},{b,2,n}],#[[1]]!=#[[2]]&];
    Select[Range[0, 1000], Q] (* Hans Rudolf Widmer, Oct 08 2022 *)
  • Python
    from itertools import count, islice
    from sympy import isprime
    def A187813_gen(startvalue=0): # generator of terms >= startvalue
        yield from filter(lambda n:n<3 or (isprime(n-1) and n.bit_count()!=2), count(max(startvalue,0)))
    A187813_list = list(islice(A187813_gen(startvalue=20),30)) # Chai Wah Wu, Mar 24 2025
  • Sage
    n=1000 #change n for more terms
    S=[]
    for i in [0..n]:
        test=False
        for b in [2..i]:
            if sum(Integer(i).digits(base=b))==b:
                test=True
                break
        if not test:
            S.append(i)
    S
    # From Hieronymus Fischer, Apr 10 2014: (Start)
    
  • Smalltalk
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 1: Using numOfBasesWithDigitalSumEQBase from A239703 ==> fast calculation, since only the divisors of  have to tested to be candidates for bases b with base-b digital sum equal to b"
      | an |
      an := self + 1.
      [an numOfBasesWithDigitalSumEQBase > 0]
      whileTrue: [an := an+1].
      ^an
    -----------
    A187813NextTerm
      "Calculates the next term of A187813 greater than the receiver, i.e., calculates a(n+1) from a(n).
      Usage: a(n) A187813NextTerm
      Answer: a(n+1)
      Version 2: Using the equivalence with A008864 and A239708 ==> even much more faster calculation"
      | p q |
      self < 0 ifTrue: [^0].
      self = 0 ifTrue: [^1].
      self = 1 ifTrue: [^2].
      p := (self - 1) nextPrime.
      q := p+1-(2 raisedToInteger: (p+1 integerFloorLog: 2)).
      [q > 0 and: [(2 raisedToInteger: (q integerFloorLog: 2)) - q = 0]] whileTrue: [p := p nextPrime.
                       q := p + 1 - (2 raisedToInteger: (p + 1 integerFloorLog: 2))].
      ^p + 1
    -----------
    A187813
      "Calculates the n-th term of A187813, iteratively.
      Usage: n A187813
      Answer: a(n)"
      | an n |
      n := self.
      n < 3 ifTrue: [^#(0 1) at: n].
      an := 2.
      4 to: n do: [:i |an := an A187813NextTerm].
      ^an
    -----------
    A187813rec
      "Calculates the n-th term of A187813, using the recursive method <A187813With: param>
      Usage: n A187813
      Answer: a(n)"
      self < 3 ifTrue: [^#(0 1) at: self].
      ^self A187813With: self prime
    -----------
    A187813With: estimate
    "Method to calculate the n-th term of A187813 based on the value estimate, recursively. The n-th prime is a adequate estimate. Valid for n > 2.
      Usage: n A187813With: estimate
      Answer: a(n)"
      | x m |
      (x:=((m:= estimate A239708inv)+self-3) prime + 1) = estimate
          ifFalse: [^self A187813With: x].
      (m + 1) A239708 = x
          ifTrue: [^self A187813With: x + 4].
      ^x
    [End]
    

Formula

From Hieronymus Fischer, Mar 27 2014: (Start)
A239703(a(n)) = 0.
a(n+1) = min (p > a(n) | A239703(p) = 0)
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 1].
a(n+1) = 1 + min (p > a(n) | p is prime AND ((q := p+1 - 2^floor(log_2(p+1)) = 0) OR (2^floor(log_2(q)) <> q)))
[for a Smalltalk implementation see Prog section, method A187813NextTerm version 2].
a(n) > Prime(n), for n > 5.
a(n - m) < Prime(n), for n > 1, where m := i*(i-1)/2 + j - 1, i := floor(log_2(Prime(n))), j := floor(log_2(Prime(n) - 2^i)).
a(n - m) < Prime(n), for n > 32, where m := i*(i-1)/2 + j - 16 with i and j above.
a(n) = Prime(n + m - 3) + 1, where m = max ( k | A239708(k) < a(n)), n > 3.
Remark: This identity can be used to calculate a(n) recursively. For a Smalltalk implementation see Prog section, methods A187813rec and A187813With: estimate.
With same conditions: a(n) = A008864(n + m - 3).
a(n - m + 3) = Prime(n) + 1, where m = max ( k | A239708(k) < Prime(n)), n > 3, provided Prime(n) + 1 is not a term of A239708.
(End)

A073267 Number of compositions (ordered partitions) of n into exactly two powers of 2.

Original entry on oeis.org

0, 0, 1, 2, 1, 2, 2, 0, 1, 2, 2, 0, 2, 0, 0, 0, 1, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Antti Karttunen, Jun 25 2002

Keywords

Comments

Starting with 1 = self-convolution of A036987, the characteristic function of the powers of 2. [Gary W. Adamson, Feb 23 2010]

Examples

			For 2 there is only composition {1+1}, for 3 there is {1+2, 2+1}, for 4 {2+2}, for 5 {1+4, 4+1}, for 6 {2+4,4+2}, for 7 none, thus a(2)=1, a(3)=2, a(4)=1, a(5)=2, a(6)=2 and a(7)=0.
		

Crossrefs

The second row of the table A073265. The essentially same sequence 1, 1, 2, 1, 2, 2, 0, 1, ... occurs for first time in A073202 as row 105 (the fix count sequence of A073290). The positions of 1's for n > 1 is given by the characteristic function of A000079, i.e. A036987 with offset 1 instead of 0 and the positions of 2's is given by A018900. Cf. also A023359.
Cf. A036987. [Gary W. Adamson, Feb 23 2010]

Programs

  • Haskell
    a073267 n = sum $ zipWith (*) a209229_list $ reverse $ take n a036987_list
    -- Reinhard Zumkeller, Mar 07 2012
    
  • Maple
    f:= proc(n) local d;
    d:= convert(convert(n,base,2),`+`);
    if d=2 then 2 elif d=1 then 1 else 0 fi
    end proc:
    0, 0, seq(f(n),n=2..100); # Robert Israel, Jul 07 2016
  • Mathematica
    Table[Count[Map[{#, n - #} &, Range[0, n]], k_ /; Times @@ Boole@ Map[IntegerQ@ Log2@ # &, k] == 1], {n, 0, 88}] (* Michael De Vlieger, Jul 08 2016 *)
  • PARI
    N=166; x='x+O('x^N);
    v=Vec( 'a0 + sum(k=0,ceil(log(N)/log(2)), x^(2^k) )^2 );
    v[1] -= 'a0;  v
    /* Joerg Arndt, Oct 21 2012 */
    
  • Python
    def A073267(n): return m if n>1 and (m:=n.bit_count())<3 else 0 # Chai Wah Wu, Oct 30 2024

Formula

G.f.: (Sum_{k>=0} x^(2^k) )^2. - Vladeta Jovovic, Mar 28 2005
a(n+1) = A000108(n) mod 4, n>=1 [Theorem 2.3 of Eu et al.]. - R. J. Mathar, Feb 27 2008
a(n) = sum (A209229(k)*A036987(n-k): k = 0..n), convolution of characteristic functions of 2^n and 2^n-1. [Reinhard Zumkeller, Mar 07 2012]
a(n+2) = A000168(n) mod 4. - John M. Campbell, Jul 07 2016

A239712 Primes of the form m = 2^i + 2^j - 1, where i > j >= 0.

Original entry on oeis.org

2, 5, 11, 17, 19, 23, 47, 67, 71, 79, 131, 191, 257, 263, 271, 383, 1031, 1039, 1087, 1151, 1279, 2063, 2111, 4099, 4111, 4127, 4159, 5119, 6143, 8447, 16447, 20479, 32771, 32783, 32831, 33023, 33791, 65537, 65539, 65543, 65551, 65599, 66047, 73727, 81919, 262147, 262151, 262271, 262399, 263167
Offset: 1

Views

Author

Hieronymus Fischer, Mar 28 2014 and Apr 22 2014

Keywords

Comments

Numbers m such that b = 2 is the only base such that the base-b digital sum of m + 1 is equal to b.
Example: 5 + 1 = 110_2 which implies ds_2(5 + 1) = 2 = b, where ds_b = digital sum in base-b. However, ds_3(6) = 2 <> 3, ds_4(6) = 3 <> 4, ds_5(6) = 2 <> 5, ds_6(6) = 1 <> 6. For all other bases > 6 we have ds_b(6) = 6 <> b. It follows that b = 2 is the only such base.
The base-2 representation of a term 2^i + 2^j - 1 has a base-2 digital sum of 1 + j.
In base-2 representation the first terms are 10, 101, 1011, 10001, 10011, 10111, 101111, 1000011, 1000111, 1001111, 10000011, 10111111, 100000001, 100000111, 100001111, 101111111, 10000000111, 10000001111, 10000111111, 10001111111, ...
Numbers m = 2^i + 2^j - 1 with odd i and j are not terms. Example: 10239 = 2^13 + 2^11 - 1 is not a prime.

Examples

			a(1) = 2, since 2 = 2^1 + 2^0 - 1 is prime.
a(5) = 19, since 19 = 2^4 + 2^2 - 1 is prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Union[Total/@(2^#&/@Subsets[Range[0,20],{2}])-1],PrimeQ] (* Harvey P. Dale, Aug 08 2014 *)
  • Smalltalk
    A239712
    "Answers the n-th term of A239712.
      Usage: n A239712
      Answer: a(n)"
      | a b i k m p q terms |
      terms := OrderedCollection new.
      b := 2.
      p := 1.
      k := 0.
      m := 0.
      [k < self] whileTrue:
             [m := m + 1.
             p := b * p.
             q := 1.
             i := 0.
             [i < m and: [k < self]] whileTrue:
                       [i := i + 1.
                       a := p + q - 1.
                       a isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q]].
      ^terms at: self
    [by Hieronymus Fischer, Apr 22 2014]
    -----------
    
  • Smalltalk
    floorPrimesWhichAreDistinctPowersOf: b withOffset: d
      "Answers an array which holds the primes < n that obey b^i + b^j + d, i>j>=0,
      where n is the receiver. b > 1 (here: b = 2, d = -1).
      Uses floorDistinctPowersOf: from A018900
      Usage:
      n floorPrimesWhichAreDistinctPowersOf: b withOffset: d
      Answer: #(2 5 11 17 19 23 ...) [terms < n]"
      ^((self - d floorDistinctPowersOf: b)
      collect: [:i | i + d]) select: [:i | i isPrime]
    [by Hieronymus Fischer, Apr 22 2014]
    ------------
    
  • Smalltalk
    primesWhichAreDistinctPowersOf: b withOffset: d
      "Answers an array which holds the n primes of the form b^i + b^j + d, i>j>=0, where n is the receiver.
      Direct calculation by scanning b^i + b^j + d in increasing order and selecting terms which are prime.
      b > 1; this sequence: b = 2, d = 1.
      Usage:
      n primesWhichAreDistinctPowersOf: b withOffset: d
      Answer: #(2 5 11 17 19 23 ...) [a(1) ... a(n)]"
      | a k p q terms n |
      terms := OrderedCollection new.
      n := self.
      k := 0.
      p := b.
      [k < n] whileTrue:
             [q := 1.
             [q < p and: [k < n]] whileTrue:
                       [a := p + q + d.
                       a isPrime
                            ifTrue:
                                [k := k + 1.
                                terms add: a].
                       q := b * q].
             p := b * p].
      ^terms asArray
    [by Hieronymus Fischer, Apr 22 2014]

Formula

a(n) = A239708(n) - 1.
a(n+1) = min(A018900(k) > a(n)| A018900(k) - 1 is prime, k >= 1) - 1.

Extensions

Examples moved from Maple field to Examples field by Harvey P. Dale, Aug 08 2014
Previous Showing 11-20 of 77 results. Next