Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main() {
int n, c = 1;
cin >> n;
for(int i = 1; c <= n; i++, c += i)
if(c == n) {
cout << "YES" << endl;
return 0;
}
cout << "NO" << endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
1
Output
YES
Demonstration
Codeforcess Solution Triangular numbers ,A. Triangular numbers C,C++, Java, Js and Python ,A. Triangular numbers,Codeforcess Solution