Find the nth number in the sequence
Submissions: 1216   Accuracy:

19.7%

  Difficulty: Basic   Marks: 1

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 Nth number in this sequence.
 

Input : 
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a positive integer which denotes N.

 

Output : 
For each test case in a new line print the Nth number in the given sequence.

 

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 1010

 

Example : 
Input : 

3
4

14
114

Output :
1
4
9

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.