clc clear all %% A program to generate unique lotto numbers % This program gives problems xlow=1; xhigh=53; n=6; for i=1:1:n lottopick(i)=floor(xlow+(xhigh-xlow+1)*rand); flag=0; for j=1:1:i-1 if (lottopick(i)==lottopick(j)) flag=1; end end if flag==1 i=i-1; end end lottopick