Re: Binary System Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg18689] Re: Binary System Problem
- From: "Ugo Marchesini" <vi13818 at iperbole.bologna.it>
- Date: Thu, 15 Jul 1999 01:46:05 -0400
- Organization: NETTuno
- References: <7mek54$9it@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Frieder Schweigert ha scritto nel messaggio <7mek54$9it at smc.vnet.net>... >Hi, > >does anybody know an algorithm or generating system for >those binary numbers with a fix amount of '1's, >for example (four times '1'): > > 1111 >10111 >11011 >11101 >11110 >. >. >.. > > >Greetings Frieder. > I hope this is the algoritm that you are looking for alg[in_]:=Module[{},p1=Sum[2^i,{i,0,in-1}]; p2=IntegerDigits[p1,2]; p3=Table[p2,{i,1,in}]; For[i=1,i<in+1,i++,p3[[i,i]]=0]; MatrixForm[p3] ] alg[7] 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0