Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Count = 0: for a = 1: n for b = 1: n count = count + 1: end for b = 1: n for c =

ID: 3867009 • Letter: C

Question

Count = 0: for a = 1: n for b = 1: n count = count + 1: end for b = 1: n for c = 1: n count = count + 1: end end for b = 1: n count = count + 1: end for b = 1: n for c = 1: n for d = 1: n count = count+1: end end end for b = 1: n count = count + 1: end end (a) Give a formula (which is a function of n) for the final value of count. (b) Insert the minimal amount of code possible to make count count up 1 at a time (ie. count = count + 1) twice as high as it is doing here. (Still start at 0, of course!).

Explanation / Answer

a) formula is n(n+n^2+n+n^3+n) = n^2 + n^3 + n^2 + n^4 + n^2

b) Questions is bit unclear please provide more info