We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Loading...

- All Contests
- ProjectEuler+
- Project Euler #42: Coded triangle numbers

# Project Euler #42: Coded triangle numbers

# Project Euler #42: Coded triangle numbers

_{This problem is a programming version of Problem 42 from projecteuler.net}

The term of a sequence of triangle numbers is given by,

so the first ten triangle numbers are:

You are given an integer. If it is a triangular number , print the term corresponding to this number, else print

**Input Format**

First line of input contains an integer denoting the number of testcases. Each of the next lines contains an integer.

**Constraints**

**Output Format**

Print the answer corresponding to each test case in a new line.

**Sample Input**

```
3
2
3
55
```

**Sample Output**

```
-1
2
10
```