**I am trying write a procedure (bit(n,k)) that print all the binary sequences with 2 following conditions:

- Each of the sequences has the length of 'n'. (n elements)

- k bits of n elements have the value 1. (all the remains have the value 0)

Example: bit(3,2) and the result is ((101),(110),(011)).

**My code:

bit := proc (n, k)

local one, index, i, d;

global A;

one := 0;

index := 1;

A := [seq(0, i = 1 .. n)];

d := proc (index)

if one = k or index = n+1 then return NULL; end if;

for i from 0 to 1 do

A[index] := i;

if i = 1 then one := one+1; end if;

if one = k then print(op(A)); end if;

d(index+1);

if i = 1 then one := one-1; A[index] := 0; end if;

end do;

end proc;

d(1);

end proc;

>bit(5,1);

result:

0, 0, 0, 0, 1

That 's not the answer for the excercise. What is the problem?