# Basic Determine exact amount of iterations

How exactly do you track the exact amount of iterations? I know its probably basic but can't figure out how so was hoping someone could explain to a complete beginner how you arrive at an answer.

def f(n):

i = 4

while i < n:

print(i)

i = i + 1


( The answer should be max(n−4,0) )

• It's not basic at all. There's no general rule to count the exact number of iterations. However, for many common programs you can mentally count them. Above we start counting from $4$ until $n$ is met, hence $n-4$. If that would be negative, instead ...
– chi
Mar 21 '17 at 15:00
• Try adding some print statements inside all this and just observe the results. Mar 23 '17 at 7:52