Say for a given positive integer number
n, you have to find a level
k so that
1 + 2 + 3 + ... + k = S is below or equals
S + k + 1 is above
For example in python:
def find_level(n): level = 1 while n > 0: n -= level level += 1 return level - 1
What is the O magnitude of this function?