I am new to the whole world of time complexity. So, I tried to read my textbook on data structures and tried to work on a problem set. I couldn't get the correct answer but I am not bothered by the answer. I want to really get the concept of calculating time complexity of algorithms. I tried the following problem set. Please help me out and kindly advise me on my error.
def program1(x):
total = 0
for i in range(1000):
total += i
while x > 0:
x -= 1
total += x
return total
Calculate the best case and worst case time complexity of the above function.