Find the sequence number of a triangular number | Java code to print sequence number of a triangular number ; If N is not tringular number
import java . util . * ; class GFG { public static void main ( String args [ ] ) { int N = 21 ; int A = ( int ) ( Math . sqrt ( 2 * N + 0.25 ) - 0.5 ) ; int B = A ; if ( B != A ) System . out . print ( " - 1" ) ; else System . out . print ( B ) ; } }