The objective is to return sum of first N natural numbers. I have used a formula to return the sum, but my solution is not accepted. Am I missing any Test Case?
int n;
cin>>n;
int x = n*(n+1)/2;
cout<<x;
The objective is to return sum of first N natural numbers. I have used a formula to return the sum, but my solution is not accepted. Am I missing any Test Case?
int n;
cin>>n;
int x = n*(n+1)/2;
cout<<x;