Description
The summation of first N positive integers is (N * (N + 1)) / 2. You are given a number X.
Find out the maximum value of N so that 1 + 2 + 3 + … + N <= X i.e. (N * (N + 1)) / 2 <= X.
Input Format
The first line contains a number T (1 ≤ T ≤ 100) number of test cases.
Each test case contains a number X (1 ≤ N ≤ 10^18). Constraints empty
Output Format
For each test case, print the maximum value of N.
Sample Input 0
Sample Output 0
Explanation 0
In the first test case:
1 + 2 + 3 + 4 + 5 + 6 = 21 which is ≤ 21 (X = 21, in this case). Here N = 6 is the maximum possible value.
In the second test case:
1 + 2 = 3 which is <= 5 (N = 8 in this case). If we consider N = 3, then the summation would be 6 which is >= 5. Thus N = 2 is the required answer.
1/1
Reviews
There are no reviews yet.