Consider the sequence of numbers 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, ... In this sequence first we have the number 1, then the numbers from 1 to 2, then the numbers from 1 to 3 and so on. Your task is to find the N'th number in this sequence.
 
Example 1:
Input: N = 4
Output: 1
Explanation: 4'th number is 1. 
Ã¢â¬â¹Example 2:
Input: N = 14
Output: 4
Explanation: 14'th number is 4.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function get() which takes N as input and returns the answer.
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{10}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3


class Solution:
    def get (self, n):
        #complete the function here

Solutions:
from math import *

class Solution:

	def get(self, n):
		num = floor((sqrt(1 + 8 * n) - 1) / 2)
		if n == num * (num + 1) // 2:
			result = num
		else:
			result = n - num * (num + 1) // 2
		return result


class Solution:

	def get(self, n):
		n = n - 1
		i = 1
		while n >= 0:
			n -= i
			i += 1
		return n + i
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.get(n))


class Solution:

	def get(self, n):
		n = n - 1
		i = 1
		while n >= 0:
			n -= i
			i += 1
		return n + i