from math import sqrt class Solution(object): def num(self, k): x = int(sqrt(2*k)) prenum = x * (x-1) / 2 result = k - prenum return int(result) if __name__ == '__main__': s = Solution() print(s.num(10))