#include <iostream>
#include <cmath>
using namespace std;
bool function(int n);
int main ()
{
int x;
cout<<"Please enter a number"<<endl;
cin>>x;
if (function(x))
cout<<"This is a triangular number"<<endl;
else
cout<<"This is not a triangular number"<<endl;
}
bool function (int n)
{
return n == (sqrt(8*n + 1) - 1) / 2;
}
when i define the function i dont check if the number i entered is a triangular one or not. I dont know how to set this math function. any ideas. i know how to find these numbers but no how to check.