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

A018900 Sums of two distinct powers of 2.

Original entry on oeis.org

3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 65, 66, 68, 72, 80, 96, 129, 130, 132, 136, 144, 160, 192, 257, 258, 260, 264, 272, 288, 320, 384, 513, 514, 516, 520, 528, 544, 576, 640, 768, 1025, 1026, 1028, 1032, 1040, 1056, 1088, 1152, 1280, 1536, 2049, 2050, 2052, 2056, 2064, 2080, 2112, 2176, 2304, 2560, 3072
Offset: 1

Views

Author

Jonn Dalton (jdalton(AT)vnet.ibm.com), Dec 11 1996

Keywords

Comments

Appears to give all k such that 8 is the highest power of 2 dividing A005148(k). - Benoit Cloitre, Jun 22 2002
Seen as a triangle read by rows, T(n,k) = 2^(k-1) + 2^n, 1 <= k <= n, the sum of the n-th row equals A087323(n). - Reinhard Zumkeller, Jun 24 2009
Numbers whose base-2 sum of digits is 2. - Tom Edgar, Aug 31 2013
All odd terms are A000051. - Robert G. Wilson v, Jan 03 2014
A239708 holds the subsequence of terms m such that m - 1 is prime. - Hieronymus Fischer, Apr 20 2014

Examples

			From _Hieronymus Fischer_, Apr 27 2014: (Start)
a(1) = 3, since 3 = 2^1 + 2^0.
a(5) = 10, since 10 = 2^3 + 2^1.
a(10^2) = 16640
a(10^3) = 35184372089344
a(10^4) = 2788273714550169769618891533295908724670464 = 2.788273714550...*10^42
a(10^5) = 3.6341936214780344527466190...*10^134
a(10^6) = 4.5332938264998904048012398...*10^425
a(10^7) = 1.6074616084721302346802429...*10^1346
a(10^8) = 1.4662184497310967196301632...*10^4257
a(10^9) = 2.3037539289782230932863807...*10^13462
a(10^10) = 9.1836811272250798973464436...*10^42571
(End)
		

Crossrefs

Cf. A000079, A014311, A014312, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 3, 4, ..., 9).
Sum of base-b digits equal b: A226636 (b = 3), A226969 (b = 4), A227062 (b = 5), A227080 (b = 6), A227092 (b = 7), A227095 (b = 8), A227238 (b = 9), A052224 (b = 10). - M. F. Hasler, Dec 23 2016

Programs

  • C
    unsigned hakmem175(unsigned x) {
        unsigned s, o, r;
        s = x & -x; r = x + s;
        o = x ^ r;  o = (o >> 2) / s;
        return r | o;
    }
    unsigned A018900(int n) {
        if (n == 1) return 3;
        return hakmem175(A018900(n - 1));
    } // Peter Luschny, Jan 01 2014
    
  • Haskell
    a018900 n = a018900_list !! (n-1)
    a018900_list = elemIndices 2 a073267_list  -- Reinhard Zumkeller, Mar 07 2012
    
  • Maple
    a:= n-> (i-> 2^i+2^(n-1-i*(i-1)/2))(floor((sqrt(8*n-1)+1)/2)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 01 2022
  • Mathematica
    Select[ Range[ 1056 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==2)& ]
    Union[Total/@Subsets[2^Range[0,10],{2}]] (* Harvey P. Dale, Mar 04 2012 *)
  • PARI
    for(m=1,9,for(n=0,m-1,print1(2^m+2^n", "))) \\ Charles R Greathouse IV, Sep 09 2011
    
  • PARI
    is(n)=hammingweight(n)==2 \\ Charles R Greathouse IV, Mar 03 2014
    
  • PARI
    for(n=0,10^5,if(hammingweight(n)==2,print1(n,", "))); \\ Joerg Arndt, Mar 04 2014
    
  • PARI
    a(n)= my(t=sqrtint(n*8)\/2); 2^t + 2^(n-1-t*(t-1)/2); \\ Ruud H.G. van Tol, Nov 30 2024
    
  • Python
    print([n for n in range(1, 3001) if bin(n)[2:].count("1")==2]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    A018900_list = [2**a+2**b for a in range(1,10) for b in range(a)] # Chai Wah Wu, Jan 24 2021
    
  • Python
    from math import isqrt, comb
    def A018900(n): return (1<<(m:=isqrt(n<<3)+1>>1))+(1<<(n-1-comb(m,2))) # Chai Wah Wu, Oct 30 2024
  • Smalltalk
    distinctPowersOf: b
      "Version 1: Answers the n-th number of the form b^i + b^j, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: a(n)"
      | n i j |
      n := self.
      i := (8*n - 1) sqrtTruncated + 1 // 2.
      j := n - (i*(i - 1)/2) - 1.
      ^(b raisedToInteger: i) + (b raisedToInteger: j)
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    distinctPowersOf: b
      "Version 2: Answers an array which holds the first n numbers of the form b^i + b^j, i>j>=0, where n is the receiver. b > 1 (b = 2, for this sequence).
      Usage: n distinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [first n terms]"
      | k p q terms |
      terms := OrderedCollection new.
      k := 0.
      p := b.
      q := 1.
      [k < self] whileTrue:
             [[q < p and: [k < self]] whileTrue:
                       [k := k + 1.
                       terms add: p + q.
                       q := b * q].
             p := b * p.
             q := 1].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    floorDistinctPowersOf: b
      "Answers an array which holds all the numbers b^i + b^j < n, i>j>=0, where n is the receiver.
      b > 1 (b = 2, for this sequence).
      Usage: n floorDistinctPowersOf: 2
      Answer: #(3 5 6 9 10 12 ...) [all terms < n]"
      | a n p q terms |
      terms := OrderedCollection new.
      n := self.
      p := b.
      q := 1.
      a := p + q.
      [a < n] whileTrue:
             [[q < p and: [a < n]] whileTrue:
                       [terms add: a.
                       q := b * q.
                       a := p + q].
             p := b * p.
             q := 1.
             a := p + q].
      ^terms as Array
    [by Hieronymus Fischer, Apr 20 2014]
    ------------
    
  • Smalltalk
    invertedDistinctPowersOf: b
      "Given a number m which is a distinct power of b, this method answers the index n such that there are uniquely defined i>j>=0 for which b^i + b^j = m, where m is the receiver;  b > 1 (b = 2, for this sequence).
      Usage: m invertedDistinctPowersOf: 2
      Answer: n such that a(n) = m, or, if no such n exists, min (k | a(k) >= m)"
      | n i j k m |
      m := self.
      i := m integerFloorLog: b.
      j := m - (b raisedToInteger: i) integerFloorLog: b.
      n := i * (i - 1) / 2 + 1 + j.
      ^n
    [by Hieronymus Fischer, Apr 20 2014]
    

Formula

a(n) = 2^trinv(n-1) + 2^((n-1)-((trinv(n-1)*(trinv(n-1)-1))/2)), i.e., 2^A002024(n)+2^A002262(n-1). - Antti Karttunen
a(n) = A059268(n-1) + A140513(n-1). A000120(a(n)) = 2. Complement of A161989. A151774(a(n)) = 1. - Reinhard Zumkeller, Jun 24 2009
A073267(a(n)) = 2. - Reinhard Zumkeller, Mar 07 2012
Start with A000051. If n is in sequence, then so is 2n. - Ralf Stephan, Aug 16 2013
a(n) = A057168(a(n-1)) for n>1 and a(1) = 3. - Marc LeBrun, Jan 01 2014
From Hieronymus Fischer, Apr 20 2014: (Start)
Formulas for a general parameter b according to a(n) = b^i + b^j, i>j>=0; b = 2 for this sequence.
a(n) = b^i + b^j, where i = floor((sqrt(8n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2 [for a Smalltalk implementation see Prog section, method distinctPowersOf: b (2 versions)].
a(A000217(n)) = (b + 1)*b^(n-1) = b^n + b^(n-1).
a(A000217(n)+1) = 1 + b^(n+1).
a(n + 1 + floor((sqrt(8n - 1) + 1)/2)) = b*a(n).
a(n + 1 + floor(log_b(a(n)))) = b*a(n).
a(n + 1) = b^2/(b+1) * a(n) + 1, if n is a triangular number (s. A000217).
a(n + 1) = b*a(n) + (1-b)* b^floor((sqrt(8n - 1) + 1)/2), if n is not a triangular number.
The next term can also be calculated without using the index n. Let m be a term and i = floor(log_b(m)), then:
a(n + 1) = b*m + (1-b)* b^i, if floor(log_b(m/(b+1))) + 1 < i,
a(n + 1) = b^2/(b+1) * m + 1, if floor(log_b(m/(b+1))) + 1 = i.
Partial sum:
Sum_{k=1..n} a(k) = ((((b-1)*(j+1)+i-1)*b^(i-j) + b)*b^j - i)/(b-1), where i = floor((sqrt(8*n - 1) + 1)/2), j = n - 1 - i*(i - 1)/2.
Inverse:
For each sequence term m, the index n such that a(n) = m is determined by n := i*(i-1)/2 + j + 1, where i := floor(log_b(m)), j := floor(log_b(m - b^floor(log_b(m)))) [for a Smalltalk implementation see Prog section, method invertedDistinctPowersOf: b].
Inequalities:
a(n) <= (b+1)/b * b^floor(sqrt(2n)+1/2), equality holds for triangular numbers.
a(n) > b^floor(sqrt(2n)+1/2).
a(n) < b^sqrt(2n)*sqrt(b).
a(n) > b^sqrt(2n)/sqrt(b).
Asymptotic behavior:
lim sup a(n)/b^sqrt(2n) = sqrt(b).
lim inf a(n)/b^sqrt(2n) = 1/sqrt(b).
lim sup a(n)/b^(floor(sqrt(2n))) = b.
lim inf a(n)/b^(floor(sqrt(2n))) = 1.
lim sup a(n)/b^(floor(sqrt(2n)+1/2)) = (b+1)/b.
lim inf a(n)/b^(floor(sqrt(2n)+1/2)) = 1.
(End)
Sum_{n>=1} 1/a(n) = A179951. - Amiram Eldar, Oct 06 2020

Extensions

Edited by M. F. Hasler, Dec 23 2016

A065442 Decimal expansion of Erdős-Borwein constant Sum_{k>=1} 1/(2^k - 1).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Nov 18 2001

Keywords

Comments

Also the decimal expansion of the (finite) value of Sum_{ k >= 1, k has no digit equal to 0 in base 2 } 1/k. - Robert G. Wilson v, Aug 03 2010
This constant is irrational (Erdős, 1948; Borwein, 1992). - Amiram Eldar, Aug 01 2020

Examples

			1.60669515241529176378330152319092458048057967150575643577807955369...
		

References

  • Steven R. Finch, Mathematical Constants, Cambridge, 2003, pp. 354-361.
  • Paul Halmos, "Problems for Mathematicians, Young and Old", Dolciani Mathematical Expositions, 1991, p. 258.

Crossrefs

See A038631 for continued fraction.

Programs

  • Maple
    # Uses Lambert series, cf. formula by Arndt:
    evalf( add( (1/2)^(n^2)*(1 + 2/(2^n - 1)), n = 1..20 ), 105);
    # Peter Bala, Jan 22 2021
  • Mathematica
    RealDigits[ Sum[1/(2^k - 1), {k, 350}], 10, 111][[1]] (* Robert G. Wilson v, Nov 05 2006 *)
    (* first install irwinSums.m, see reference, then *) First@ RealDigits@ iSum[0, 0, 111, 2] (* Robert G. Wilson v, Aug 03 2010 *)
    RealDigits[(Log[2] - 2 QPolyGamma[0, 1, 2])/Log[4], 10, 100][[1]] (* Fred Daniel Kline, May 23 2011 *)
    x = 1/2; RealDigits[ Sum[ DivisorSigma[0, k] x^k, {k, 1000}], 10, 105][[1]] (* Robert G. Wilson v, Oct 12 2014 after an observation and formula of Amarnath Murthy, see A073668 *)
  • PARI
    a(n)= s=0; for(x=1,n,s=s+1.0/(2^x-1)); s
    
  • PARI
    default(realprecision, 2080); x=suminf(k=1, 1/(2^k - 1)); for (n=1, 2000, d=floor(x); x=(x-d)*10; write("b065442.txt", n, " ", d)) \\ Harry J. Smith, Oct 19 2009
    
  • PARI
    k=1.; suminf(n=1, k>>=1; k^n*(1+k)/(1-k)) \\ Charles R Greathouse IV, Jun 03 2015

Formula

Note: Sum_{k>=1} d(k)/2^k = Sum_{k>=1} 1/(2^k - 1).
Fast computation via Lambert series: 1.60669515... = Sum_{n>=1} x^(n^2)*(1+x^n)/(1-x^n) where x=1/2. - Joerg Arndt, May 24 2011
Equals (1/2) * A211705. - Amiram Eldar, Aug 01 2020
Equals 1/4 + Sum_{k >= 2} (1 + 8^k)/((2^k - 1)*2^(k^2+k)). See Mathematics Stack Exchange link. - Peter Bala, Jan 28 2022
Equals A066766 - A065443. - Amiram Eldar, Oct 16 2022

Extensions

More terms from Randall L Rathbun, Jan 16 2002

A048645 Integers with one or two 1-bits in their binary expansion.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 36, 40, 48, 64, 65, 66, 68, 72, 80, 96, 128, 129, 130, 132, 136, 144, 160, 192, 256, 257, 258, 260, 264, 272, 288, 320, 384, 512, 513, 514, 516, 520, 528, 544, 576, 640, 768, 1024, 1025, 1026, 1028, 1032
Offset: 1

Views

Author

Antti Karttunen, Jul 14 1999

Keywords

Comments

Apart from initial 1, sums of two not necessarily distinct powers of 2.
4 does not divide C(2s-1,s) (= A001700[ s ]) if and only if s=a(n).
Possible number of sides of a regular polygon such that there exists a triangulation where each triangle is isosceles. - Sen-peng Eu, May 07 2008
Also numbers n such that n!/2^(n-2) is an integer. - Michel Lagneau, Mar 28 2011
It appears these are also the indices of the terms that are shared by the cellular automata of A147562, A162795, A169707. - Omar E. Pol, Feb 21 2015
Numbers with binary weight 1 or 2. - Omar E. Pol, Feb 22 2015

Examples

			From _Omar E. Pol_, Feb 18 2015: (Start)
Also, written as a triangle T(j,k), k >= 1, in which row lengths are the terms of A028310:
   1;
   2;
   3,  4;
   5,  6,  8;
   9, 10, 12, 16;
  17, 18, 20, 24, 32;
  33, 34, 36, 40, 48, 64;
  65, 66, 68, 72, 80, 96, 128;
  ...
It appears that column 1 is A094373.
It appears that the right border gives A000079.
It appears that the first differences in every row that contains at least two terms give the first h-1 powers of 2, where h is the length of the row.
(End)
		

Crossrefs

Programs

  • Haskell
    import Data.List (insert)
    a048645 n k = a048645_tabl !! (n-1) !! (k-1)
    a048645_row n = a048645_tabl !! (n-1)
    a048645_tabl = iterate (\xs -> insert (2 * head xs + 1) $ map ((* 2)) xs) [1]
    a048645_list = concat a048645_tabl
    -- Reinhard Zumkeller, Dec 19 2012
    
  • Maple
    lincom:=proc(a,b,n) local i,j,s,m; s:={}; for i from 0 to n do for j from 0 to n do m:=a^i+b^j; if m<=n then s:={op(s),m} fi od; od; lprint(sort([op(s)])); end: lincom(2,2,1000); # Zerinvary Lajos, Feb 24 2007
  • Mathematica
    Select[Range[2000], 1 <= DigitCount[#, 2, 1] <= 2&] (* Jean-François Alcover, Mar 06 2016 *)
  • PARI
    isok(n) = my(hw = hammingweight(n)); (hw == 1) || (hw == 2); \\ Michel Marcus, Mar 06 2016
    
  • PARI
    a(n) = if(n <= 2, return(n), n-=2); my(c = (sqrtint(8*n + 1) - 1) \ 2); 1 << c + 1 << (n - binomial(c + 1, 2)) \\ David A. Corneth, Jan 02 2019
    
  • PARI
    nxt(n) = msb = 1 << logint(n, 2); if(n == msb, n + 1, t = n - msb; n + t) \\ David A. Corneth, Jan 02 2019
    
  • Python
    def ok(n): return 1 <= bin(n)[2:].count('1') <= 2
    print([k for k in range(1033) if ok(k)]) # Michael S. Branicky, Jan 22 2022
    
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        for d in count(0):
            msb = 2**d
            yield msb
            for lsb in range(d):
                yield msb + 2**lsb
    print(list(islice(agen(), 60))) # Michael S. Branicky, Jan 22 2022
    
  • Python
    from math import isqrt, comb
    def A048645(n): return (1<<(m:=isqrt(n-1<<3)+1>>1)-1)+(1<<(n-2-comb(m,2))) if n>1 else 1 # Chai Wah Wu, Oct 30 2024

Formula

a(0) = 1, a(n) = (2^(trinv(n-1)-1) + 2^((n-1)-((trinv(n-1)*(trinv(n-1)-1))/2))), i.e., 2^A003056(n) + 2^A002262(n-1) (the latter sequence contains the definition of trinv).
Let Theta = Sum_{k >= 0} x^(2^k). Then Sum_{n>=1} x^a(n) = (Theta^2 + Theta + x)/2. - N. J. A. Sloane, Jun 23 2009
As a triangle, for n > 1, 1 < k <= n: T(n,1) = A173786(n-2,n-2) and T(n,k) = A173786(n-1,k-2). - Reinhard Zumkeller, Feb 28 2010
It appears that A147562(a(n)) = A162795(a(n)) = A169707(a(n)). - Omar E. Pol, Feb 19 2015
Sum_{n>=1} 1/a(n) = 2 + A179951. - Amiram Eldar, Jan 22 2022

A323482 Decimal expansion of 1/2 + 1/3 + 1/5 + ... + 1/(2^n + 1) + ...

Original entry on oeis.org

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

Views

Author

Clark Kimberling, Jan 15 2019

Keywords

Examples

			1.2644997803484442091913...
		

Crossrefs

Programs

  • Maple
    evalf((1/2) + add( (-1)^(n+1)*((4^n + 1)/(4^n - 1))*(1/2)^(n^2), n = 1..18), 100); # Peter Bala, Jan 28 2022
  • Mathematica
    s = Sum[1/(2^k + 1), {k, 0, Infinity}]
    r = N[Re[s], 200]
    RealDigits[r][[1]]
  • PARI
    suminf(k=0, 1/(2^k+1)) \\ Michel Marcus, Jan 15 2019

Formula

From Amiram Eldar, Jun 30 2020: (Start)
Equals 1/2 + Sum_{k>=1} (-1)^(k+1)/(2^k-1)
Equals Sum_{k>=1} (mu(k) - (-1)^k)/(2^k-1), where mu is the Möbius function (A008683).
Equals (1 + A179951)/2. (End)
Equals (1/2) + Sum_{n >= 1} (-1)^(n+1)*((4^n + 1)/(4^n - 1))*(1/2)^(n^2). The first 18 terms of the series gives the constant correct to more than 100 decimal places. - Peter Bala, Jan 28 2022

A367110 Decimal expansion of Sum_{k has exactly 3 bits equal to 1 in base 2} 1/k.

Original entry on oeis.org

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

Views

Author

Tengiz Gogoberidze, Dec 16 2023

Keywords

Comments

For 1 bit equal to 1 the sum is 2, for 2 bits equal to 1 the sum is 1.52899956069688841838263949451... (see A179951).

Examples

			1.4285915458526381...
		

Crossrefs

Programs

  • Mathematica
    RealDigits[iSum[1, 3, 105, 2]][[1]] (* Amiram Eldar, Dec 16 2023, using Baillie's irwinSums.m *)

Formula

Equals Sum_{m>=2} Sum_{j=1..m-1} Sum_{i=0..j-1} 1/(2^i + 2^j + 2^m).
Equals 2 * Sum_{j>=2} Sum_{i=1..j-1} 1/(2^i + 2^j + 1).
Equals Sum_{k>=1} 1/A014311(k).
Showing 1-5 of 5 results.