Find the sequence number of a triangular number | C ++ code to print sequence number of a triangular number ; If N is not tringular number
#include <bits/stdc++.h> NEW_LINE using namespace std ; int main ( ) { int N = 21 ; int A = sqrt ( 2 * N + 0.25 ) - 0.5 ; int B = A ; if ( B != A ) cout << " - 1" ; else cout << B ; }