# Analyzing an Algorithm for Assignment Statements

For the following algorithm find the number of times the assignment statement (:=) is executed during the running of the program. Answer the question by giving a formula in terms of n:

i := 1;

while i < n + 1 do

i := i + 2;

for j := 1 to i do S od

od

https://brainmass.com/math/discrete-math/analyzing-algorithm-assignment-statements-32324

#### Solution Preview

Solution:

Assume the number of times is m.

From i:=1 we can get the number of time for this part is 1;

From i:=i+2 we ...

#### Solution Summary

The solution finds the number of times the assignment statement is executed during the running of the program.

$2.49