% Lotto Program % This is the lotto program where one can select m numbers from xlow to % xhigh. clc xlow=1; xhigh=53; m=6; % using the random number generator rand to get the lotto numbers. rand % generates numbers between 0 and 1. So we multiply that by xhigh-xlow+1 % and shift it by xlow and then floor it to get the integer part. 1 is % added as rand will always be strictly >0 and strictly <1. for i=1:m lottonum(i)=floor(xlow+rand*(xhigh-xlow+1)); end lottonum % This program picks unique numbers xlow=1; xhigh=53; m=6; i=1; while (i<=m) lottonum(i)=floor(xlow+rand*(xhigh-xlow+1)); flag=0; for j=1:i-1 if (lottonum(i)==lottonum(j)) flag=1; end end if flag==0 i=i+1; end end lottonum