% Roll dice and look at the sum.

n=10000
rec=NaN(n,1); % Record our results here.

numdice=3

for i=1:n
    roll=ceil(6*rand(numdice,1));
    total=sum(roll);
    rec(i)=total;
end

hist(rec,numdice:(numdice*6))