#K55467. Triangular Number Checker
Triangular Number Checker
Triangular Number Checker
Given a positive integer ( x ), determine if it is a triangular number. A triangular number ( T_n ) is defined as ( T_n = \frac{n(n+1)}{2} ) for some positive integer ( n ). If ( x ) equals ( T_n ) for some ( n ), output that value of ( n ); otherwise, output (-1). The input is provided via standard input and the result should be printed to standard output.
inputFormat
The input consists of a single integer ( x ) provided on standard input.
outputFormat
Output a single integer to standard output: the value of ( n ) if ( x ) is the nth triangular number, or (-1) if ( x ) is not a triangular number.## sample
3
2