function [] = Toss3Dice(SumX) m = 1; if (SumX > 0) & (SumX < 18) then for i = 1:6 for j = 1:6 for k = 1:6 x = i + j + k; if x == SumX then PossOutput(m) = strcat([string(i), string(j), string(k)]); m = m + 1; end end end end else printf('Number %d is out of range', SumX); end if m>1 then printf('There are %d event that the sum is %d\n',m-1,SumX); printf('All events are:\n'); for i = 1:m-1 printf('%s\n', PossOutput(i)); end end endfunction