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.

A383666 Numbers in whose binary representation no bit (0 or 1) occurs exactly once.

This page as a plain text file.
%I A383666 #34 May 21 2025 12:40:18
%S A383666 3,7,9,10,12,15,17,18,19,20,21,22,24,25,26,28,31,33,34,35,36,37,38,39,
%T A383666 40,41,42,43,44,45,46,48,49,50,51,52,53,54,56,57,58,60,63,65,66,67,68,
%U A383666 69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86
%N A383666 Numbers in whose binary representation no bit (0 or 1) occurs exactly once.
%C A383666 Also numbers that are not a power of 2 and are not (2^k + 1) away from the next larger power of 2 for some k. - _David A. Corneth_, May 17 2025
%H A383666 David A. Corneth, <a href="/A383666/b383666.txt">Table of n, a(n) for n = 1..10000</a>
%e A383666 From _David A. Corneth_, May 17 2025: (Start)
%e A383666 3 = 11_2 is in the sequence as both the digits 0 and the digits 1 do not occur exactly once in the binary expansion. Also 3 is no power of 2 and one less than a power of 2.
%e A383666 6 = 101_2 is not in the sequence as the digit 0 occurs exactly once in the binary expansion. Also it can be written as 2^3 - 2^0 - 1. (End)
%p A383666 filter:= proc(n) local L,n1,n0;
%p A383666   L:= convert(n,base,2);
%p A383666   n1:= convert(L,`+`);
%p A383666   n0:= nops(L)-n1;
%p A383666   n1 >= 2 and n0 <> 1
%p A383666 end proc;
%p A383666 select(filter, [$1..1000]); # _Robert Israel_, May 13 2025
%t A383666 s = Select[Range[200], DigitCount[#, 2, 0] != 1 && DigitCount[#, 2, 1] != 1 &]
%t A383666 Map[First, RealDigits[s, 2]]
%o A383666 (PARI) isok(k) = my(b=binary(k)); (#select(x->(x==1), b) != 1) && (#select(x->(x==0), b) != 1); \\ _Michel Marcus_, May 13 2025
%o A383666 (PARI) is(n) = {
%o A383666     my(v = valuation(n, 2));
%o A383666     if(n >> v == 1, return(0));
%o A383666     if(1<<valuation(n+1,2) == n+1, return(1));
%o A383666     c = 1 << (logint(n, 2) + 1) - n - 1;
%o A383666     if(c >> valuation(c, 2) == 1, return(0));
%o A383666     1
%o A383666 } \\ _David A. Corneth_, May 17 2025
%o A383666 (PARI) upto(n) = {
%o A383666     my(res = [1..n], del = List());
%o A383666     for(i = 0, logint(n, 2)+1,
%o A383666         pow2 = 1<<i;
%o A383666         listput(del, pow2);
%o A383666         for(j = 0, i-2,
%o A383666             listput(del, pow2 - 1<<j - 1);
%o A383666         );
%o A383666     );	
%o A383666     setminus(res, Set(del));
%o A383666 } \\ _David A. Corneth_, May 17 2025
%o A383666 (Python)
%o A383666 def A383666(n):
%o A383666     def f(x):
%o A383666         if x<=1: return n+x
%o A383666         l, s = x.bit_length(), bin(x)[2:]
%o A383666         if (m:=s.count('0'))>0: return n+s.index('0')-(m>1)+(l*(l-1)>>1)
%o A383666         return n-1+(l*(l+1)>>1)
%o A383666     m, k = n, f(n)
%o A383666     while m != k: m, k = k, f(k)
%o A383666     return m # _Chai Wah Wu_, May 21 2025
%Y A383666 Cf. A030130, A158581, A383667.
%K A383666 nonn,base,easy
%O A383666 1,1
%A A383666 _Clark Kimberling_, May 07 2025