## anonymous one year ago Consider the following algorithm. for i is in {1, 2, 3, 4} do beep for j is in {1, 2, 3, 4} do beep for k is in {1, 2, 3} do for l is in {1, 2, 3, 4, 5, 6} do beep for m is in {1, 2, 3, 4, 5} do beep How many times does a beep statement get executed?

1. IrishBoy123

check the indents which are absolutely crucial but indexed like this in Python ==> **152** times x = 0 for i in range(1,5): x+=1 for j in range(1,5): x+=1 for k in range(1,4): for l in range(1,7): x+=1 for m in range(1,6): x+=1 print x NB "range" doesn't run on the last item in Python so range(1,5) $$\equiv$$ {1,2,3,4} assuming that is how your source works

2. anonymous

Thank you! I tried calculating, but did not get it. So, I have to add 1 to every range? and then add them all together and multiply by 4? is that how you got the final answer?

3. IrishBoy123

no i just re-wrote the instructions in Python and ran it you could work it out by hand, of course you could.