100% Guaranteed Results


Project
$ 24.99
Category:

Description

5/5 – (1 vote)

This problem is a programming version of Problem 42 from projecteuler.net
The nth term of a sequence of triangle numbers is given by,
1
tn = n(n + 1)
2
so the first ten triangle numbers are:
1,3,6,10,15,21,28,36,45,55,⋯
You are given an integer. If it is a triangular number tn, print the term n corresponding to this number, else print −1
Input Format
First line of input contains an integer T denoting the number of testcases. Each of the next T lines contains an integer.
Output Format
Print the answer corresponding to each test case in a new line.
Constraints
5
1 ≤ T ≤ 10
18
1 ≤ tn ≤ 10
Sample Input #00:

Sample Output #00:

Reviews

There are no reviews yet.

Be the first to review “Project”

Your email address will not be published. Required fields are marked *

Related products