login
Smallest composite number with exactly n 1's in binary representation.
4

%I #15 Dec 16 2021 07:36:41

%S 4,6,14,15,55,63,247,255,511,1023,2047,4095,12287,16383,32767,65535,

%T 196607,262143,983039,1048575,2097151,4194303,8388607,16777215,

%U 33554431,67108863,134217727,268435455,536870911,1073741823,3221225471

%N Smallest composite number with exactly n 1's in binary representation.

%H Robert Israel, <a href="/A089226/b089226.txt">Table of n, a(n) for n = 1..3318</a>

%F A000120(a(n)) = n; A023416(a(n)) <= 1 for n>1. - _Ray Chandler_, Feb 15 2004

%F a(n) = A000225(n) unless n is in A000043. - _Robert Israel_, Jun 20 2019

%p f:= proc(n) local i,t;

%p for i from n to 0 by -1 do

%p t:= 2^(n+1) - 2^i - 1;

%p if not isprime(t) then return t fi

%p od

%p end proc:

%p f(1):= 4:

%p map(f, [$1..100]); # _Robert Israel_, Jun 20 2019

%t a[n_] := Module[{i, t},

%t For[i = n, i >= 0, i--,

%t t = 2^(n+1) - 2^i - 1;

%t If[!PrimeQ[t], Return [t]]]];

%t a[1] = 4;

%t Array[a, 100] (* _Jean-François Alcover_, Dec 16 2021, after _Robert Israel_ *)

%Y Cf. A000043, A000120, A000225, A023416, A061712.

%K nonn,base

%O 1,1

%A _Reinhard Zumkeller_, Dec 10 2003

%E More terms from _Ray Chandler_, Feb 15 2004