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.

A014312 Numbers with exactly 4 ones in binary expansion.

This page as a plain text file.
%I A014312 #82 Mar 10 2025 13:03:03
%S A014312 15,23,27,29,30,39,43,45,46,51,53,54,57,58,60,71,75,77,78,83,85,86,89,
%T A014312 90,92,99,101,102,105,106,108,113,114,116,120,135,139,141,142,147,149,
%U A014312 150,153,154,156,163,165,166,169,170,172,177,178,180,184,195,197
%N A014312 Numbers with exactly 4 ones in binary expansion.
%H A014312 T. D. Noe and Ivan Neretin, <a href="/A014312/b014312.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from T. D. Noe)
%H A014312 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.
%F A014312 a(n+1) = A057168(a(n)). - _M. F. Hasler_, Aug 27 2014
%F A014312 a(n) = 2^A194882(n-1) + 2^A194883(n-1) + 2^A194884(n-1) + 2^A127324(n-1). - _Ridouane Oudra_, Sep 06 2020
%F A014312 Sum_{n>=1} 1/a(n) = 1.399770961748474333075618147113153558623203796657745865012742162098738541849... (calculated using Baillie's irwinSums.m, see Links). - _Amiram Eldar_, Feb 14 2022
%t A014312 Select[ Range[ 180 ], (Count[ IntegerDigits[ #, 2 ], 1 ]==4)& ] (* _Olivier Gérard_ *)
%o A014312 (Perl) $N = 4;
%o A014312 my $vector = 2 ** $N - 1;  # first key (15)
%o A014312 for (1..100) {
%o A014312   print "$vector, ";
%o A014312   my ($v, $d) = ($vector, 0);
%o A014312   until ($v & 1 or !$v) { $d = ($d << 1)|1; $v >>= 1 }
%o A014312   $vector += $d + 1 + (($v ^ ($v + 1)) >> 2);  # next key
%o A014312 } # _Ruud H.G. van Tol_, Mar 02 2014
%o A014312 (PARI) for(n=0,10^3,if(hammingweight(n)==4,print1(n,", "))); \\ _Joerg Arndt_, Mar 04 2014
%o A014312 (PARI) print1(t=15); for(i=2, 50, print1(", "t=A057168(t))) \\ _M. F. Hasler_, Aug 27 2014
%o A014312 (Python)
%o A014312 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
%o A014312 (Python)
%o A014312 from itertools import islice
%o A014312 def A014312_gen(): # generator of terms
%o A014312     yield (n:=15)
%o A014312     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 A014312 A014312_list = list(islice(A014312_gen(),20)) # _Chai Wah Wu_, Mar 10 2025
%o A014312 (Rust)
%o A014312 pub const fn next_choice(value: usize) -> usize {
%o A014312   // Passing a term will return the next number in the sequence
%o A014312   let zeros = value.trailing_zeros();
%o A014312   let ones = (value >> zeros).trailing_ones();
%o A014312   value + (1 << zeros) + (1 << (ones - 1)) - 1
%o A014312 } // _Andrew Bennett_, Jan 07 2022
%Y A014312 Cf. A090706.
%Y A014312 Cf. A000079, A018900, A014311, A014313, A023688, A023689, A023690, A023691 (Hamming weight = 1, 2, ..., 9), A057168.
%Y A014312 Cf. A194882, A194883, A194884, A127324.
%K A014312 nonn,base,easy
%O A014312 1,1
%A A014312 Al Black (gblack(AT)nol.net)
%E A014312 Extension by _Olivier Gérard_