Initially the list contains the integer . In each step, you delete the smallest element from the list and then add the elements and into the list. What is the smallest element of the list after steps?
For example when , the list changes as follows:
In this case, the smallest element at the end is .
The time complexity of the algorithm should be .
In a file twothree.py
, implement a function smallest
that returns the desired answer.
def smallest(n): # TODO if __name__ == "__main__": print(smallest(1)) # 2 print(smallest(5)) # 6 print(smallest(123)) # 288 print(smallest(55555)) # 663552