179k views
2 votes
function summedValue = SummationWithLoop(userNum) % Summation of all values from 1 to userNum summedValue = 0; i = 1; % Write a while loop that assigns summedValue with the % sum of all values from 1 to userNum end

User Otissv
by
3.9k points

1 Answer

6 votes

Answer:

function summedValue = SummationWithLoop(userNum)

% Summation of all values from 1 to userNum

summedValue = 0;

i = 0;

% use a while loop that assigns summedValue with the

% sum of all values from 1 to userNum

while(i <= userNum)

summedValue = summedValue + i;

i = i + 1;

end

end

User Thomas Pons
by
3.8k points