function y = bin(n)
m=1;
remainder=0;
s = 0;
while (remainder ~= n)
   s = s+1;
   x = rem((n-remainder)/m,2);
   remainder = remainder + x*m;
   m = m*2;
   y(s) = x;
end
%   y=zeros(1,s);
%m=1;
%remainder=0;
%i=0;
%while (remainder ~= n)
%   y(s-i) = rem((n-remainder)/m,2);
%   remainder = remainder + y(s-i)*m;
%   m = m*2;
%   i = i+1;
%end
z=y;
for i=1:s
 y(s+1-i)=z(i);
end