MATLAB: Summation of Random Numbers

randomsumsummation

How would you go about writing a code to solve a summations of randomly generated intergers, say r= to an equation, until the sum is greater than a number, say x.

Best Answer

I would use a while loop.
while summation <= x
%add a random integer to the summation
end