%I #18 Jan 17 2020 03:31:56
%S 2,4,6,10,12,16,18,24,36,40,42,48,55,60,80,84,108,110,120,126,132,144,
%T 156,172,180,184,192,204,212,216,222,228,232,240,246,252,256,276,300,
%U 318,324,336,340,360,366,378,414,420,438,440,444,460,462,474,480,486
%N Numbers n such that both the number of non-leading 0's in the binary representation of n and the number of 1's in the binary representation of n divide n.
%H Robert Israel, <a href="/A117891/b117891.txt">Table of n, a(n) for n = 1..10000</a>
%e 24 is 11000 in binary. This binary representation has three 0's and 3 divides 24. Also, the binary representation has two 1's and 2 also divides 24. So 24 is in the sequence.
%p filter:= proc(n) local L, x,m;
%p L:= convert(n,base,2);
%p x:= convert(L,`+`);
%p m:= nops(L);
%p x < m and n mod x = 0 and n mod (m-x) = 0
%p end proc:
%p select(filter, [$1..1000]);
%t bdQ[n_]:=Module[{idn2=IntegerDigits[n,2],x,y},x=Count[idn2,1];y=Count[ idn2,0]; If[x==0,x=n+1];If[y==0,y=n+1];And@@Divisible[n,{x,y}]]; Select[ Range[500],bdQ] (* _Harvey P. Dale_, Jan 22 2012 *)
%o (C) #include <stdio.h> int main(int argc, char *argv[]) { for(int n=1; n< 500 ; n++) { int digs[2] ; int nshifted=n ; digs[0]=digs[1]=0 ; while(nshifted) { digs[ nshifted & 1]++ ; nshifted >>= 1 ; } if ( digs[0] && digs[1]) if( ( n % digs[0]) == 0 && (n %digs[1]) ==0) printf("%d,",n) ; } } /* _R. J. Mathar_, Apr 03 2006 */
%Y Cf. A049445, A117890. Includes A001146.
%K easy,nonn,base
%O 1,1
%A _Leroy Quet_, Mar 30 2006
%E More terms from _R. J. Mathar_, Apr 03 2006