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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #42: Coded triangle numbers

Project Euler #42: Coded triangle numbers

Problem
Submissions
Leaderboard
Discussions

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

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

3780

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy