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.

A014311 Numbers with exactly 3 ones in binary expansion.

This page as a plain text file.
%I A014311 #80 Mar 10 2025 15:05:55
%S A014311 7,11,13,14,19,21,22,25,26,28,35,37,38,41,42,44,49,50,52,56,67,69,70,
%T A014311 73,74,76,81,82,84,88,97,98,100,104,112,131,133,134,137,138,140,145,
%U A014311 146,148,152,161,162,164,168,176,193,194,196,200,208,224,259,261,262,265,266,268,273,274,276,280,289,290,292,296,304
%N A014311 Numbers with exactly 3 ones in binary expansion.
%C A014311 Equivalently, sums of three distinct powers of 2.
%C A014311 Appears to give all n such that 64 is the highest power of 2 dividing A005148(n). - _Benoit Cloitre_, Jun 22 2002
%C A014311 From _Gus Wiseman_, Oct 05 2020: (Start)
%C A014311 These are numbers k such that the k-th composition in standard order has length 3. The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions. The sequence together with the corresponding standard compositions begins:
%C A014311       7: (1,1,1)     44: (2,1,3)     97: (1,5,1)
%C A014311      11: (2,1,1)     49: (1,4,1)     98: (1,4,2)
%C A014311      13: (1,2,1)     50: (1,3,2)    100: (1,3,3)
%C A014311      14: (1,1,2)     52: (1,2,3)    104: (1,2,4)
%C A014311      19: (3,1,1)     56: (1,1,4)    112: (1,1,5)
%C A014311      21: (2,2,1)     67: (5,1,1)    131: (6,1,1)
%C A014311      22: (2,1,2)     69: (4,2,1)    133: (5,2,1)
%C A014311      25: (1,3,1)     70: (4,1,2)    134: (5,1,2)
%C A014311      26: (1,2,2)     73: (3,3,1)    137: (4,3,1)
%C A014311      28: (1,1,3)     74: (3,2,2)    138: (4,2,2)
%C A014311      35: (4,1,1)     76: (3,1,3)    140: (4,1,3)
%C A014311      37: (3,2,1)     81: (2,4,1)    145: (3,4,1)
%C A014311      38: (3,1,2)     82: (2,3,2)    146: (3,3,2)
%C A014311      41: (2,3,1)     84: (2,2,3)    148: (3,2,3)
%C A014311      42: (2,2,2)     88: (2,1,4)    152: (3,1,4)
%C A014311 (End)
%H A014311 Reinhard Zumkeller, <a href="/A014311/b014311.txt">Table of n, a(n) for n = 1..10000</a>
%H A014311 Robert Baillie, <a href="http://arxiv.org/abs/0806.4410">Summing the curious series of Kempner and Irwin</a>, arXiv:0806.4410 [math.CA], 2008-2015. See p. 18 for Mathematica code irwinSums.m.
%H A014311 Stephen Morley, <a href="http://code.stephenmorley.org/articles/hakmem-item-175/">HAKMEM Item 175 (Gosper)</a>.
%H A014311 Tilman Piesk, <a href="https://commons.wikimedia.org/wiki/File:8_choose_3_array_with_simplex_coordinates.svg">First 56 elements in a tetrahedral array</a>.
%F A014311 A000120(a(n)) = 3. - _Reinhard Zumkeller_, May 03 2012
%F A014311 Start with A084468. If n is in sequence, then 2n is too. - _Ralf Stephan_, Aug 16 2013
%F A014311 a(n+1) = A057168(a(n)). - _M. F. Hasler_, Aug 27 2014
%F A014311 a(n) = 2^A056558(n-1) + 2^A194848(n-1) + 2^A194847(n-1). - _Ridouane Oudra_, Sep 06 2020
%F A014311 Sum_{n>=1} 1/a(n) = A367110 = 1.428591545852638123996854844400537952781688750906133068397189529775365950039... (calculated using Baillie's irwinSums.m, see Links). - _Amiram Eldar_, Feb 14 2022
%t A014311 Select[Range[200], (Count[IntegerDigits[#, 2], 1] == 3)&]
%t A014311 nn = 8; Flatten[Table[2^i + 2^j + 2^k, {i, 2, nn}, {j, 1, i - 1}, {k, 0, j - 1}]] (* _T. D. Noe_, Nov 05 2013 *)
%o A014311 (Haskell)
%o A014311 a014311 n = a014311_list !! (n-1)
%o A014311 a014311_list = [2^x + 2^y + 2^z |
%o A014311                 x <- [2..], y <- [1..x-1], z <- [0..y-1]]
%o A014311 -- _Reinhard Zumkeller_, May 03 2012
%o A014311 (C)
%o A014311 unsigned hakmem175(unsigned x) {
%o A014311     unsigned s, o, r;
%o A014311     s = x & -x;  r = x + s;
%o A014311     o = r ^ x;  o = (o >> 2) / s;
%o A014311     return r | o;
%o A014311 }
%o A014311 unsigned A014311(int n) {
%o A014311     if (n == 1) return 7;
%o A014311     return hakmem175(A014311(n - 1));
%o A014311 }  // _Peter Luschny_, Jan 01 2014
%o A014311 (PARI) for(n=0,10^3,if(hammingweight(n)==3,print1(n,", "))); \\ _Joerg Arndt_, Mar 04 2014
%o A014311 (PARI) print1(t=7);for(i=2,50,print1(","t=A057168(t))) \\ _M. F. Hasler_, Aug 27 2014
%o A014311 (Python)
%o A014311 A014311_list = [2**a+2**b+2**c for a in range(2,6) for b in range(1,a) for c in range(b)] # _Chai Wah Wu_, Jan 24 2021
%o A014311 (Python)
%o A014311 from itertools import islice
%o A014311 def A014311_gen(): # generator of terms
%o A014311     yield (n:=7)
%o A014311     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)
%o A014311 A014311_list = list(islice(A014311_gen(),20)) # _Chai Wah Wu_, Mar 10 2025
%o A014311 (Python)
%o A014311 from math import isqrt, comb
%o A014311 from sympy import integer_nthroot
%o A014311 def A014311(n): return (1<<(r:=n-1-comb((m:=integer_nthroot(6*n,3)[0])+(t:=(n>comb(m+2,3)))+1,3))-comb((k:=isqrt(b:=r+1<<1))+(b>k*(k+1)),2))+(1<<(a:=isqrt(s:=n-comb(m-(t^1)+2,3)<<1))+((s<<2)>(a<<2)*(a+1)+1))+(1<<m+t+1) # _Chai Wah Wu_, Mar 10 2025
%Y A014311 Cf. A038465 (base 3), A038471 (base 4), A038475 (base 5).
%Y A014311 Cf. A081091 (primes), A212190 (squares), A212192 (triangular numbers), A173589 (Fibbinary).
%Y A014311 Cf. A057168.
%Y A014311 Cf. A000079, A018900, A014311, A014312, A014313, A023688, A023689, A023690, A023691 (Hammingweight = 1, 2, ..., 9).
%Y A014311 Cf. A056558, A194848, A194847.
%Y A014311 A000217(n-2) counts compositions into three parts.
%Y A014311 A001399(n-3) = A069905(n) = A211540(n+2) counts the unordered case.
%Y A014311 A001399(n-6) = A069905(n-3) = A211540(n-1) counts the unordered strict case.
%Y A014311 A001399(n-6)*6 = A069905(n-3)*6 = A211540(n-1)*6 counts the strict case.
%Y A014311 A014612 is an unordered version, with strict case A007304.
%Y A014311 A337453 is the strict case.
%Y A014311 A337461 counts the coprime case.
%Y A014311 A033992 lists numbers divisible by exactly three different primes.
%Y A014311 A323024 lists numbers with exactly three different prime multiplicities.
%Y A014311 Cf. A220377, A307534, A337459, A337460, A337561, A337603, A337604.
%K A014311 nonn,base,easy
%O A014311 1,1
%A A014311 Al Black (gblack(AT)nol.net)
%E A014311 Extension and program by _Olivier Gérard_