#include
using namespace std;
int main() {
int n;
std::cin>>n;
std::cout<<n*(n+1)/2;
return 0;
}
It is not accepting my code in learn dsa series . Please tell me the reason.
#include
using namespace std;
int main() {
int n;
std::cin>>n;
std::cout<<n*(n+1)/2;
return 0;
}
It is not accepting my code in learn dsa series . Please tell me the reason.
You should provide the question link. Assuming you are asking about the sum of natural numbers question, the range of n is [1,1e9] so use ‘long long int’ instead of int.