x=zeros(500,1);
x(1)=input('Enter inital positive integer');
k=1;
while (x(k)~=1)&(k<1000) 
	if rem(x(k),2)==0
		x(k+1)=x(k)/2;
	else
		x(k+1)=3*x(k)+1;
	end
	k=k+1;
end
n=k;
x=x(1:n);
