https://www.codechef.com/CCSTART2/problems/ADDNATRL

https://www.codechef.com/CCSTART2/problems/ADDNATRL!Screenshot (59)|690x387
i was doing this problem.during submission it is showing wrong answer eventhough it is showing correct output for all case.please someone help me

Your logic is correct. Just use long int or long long instead of int for n and sum as contraints are till 10^9. It should give AC then.

You might search your doubt on the forum before posting straightaway.

1 Like

#include
using namespace std;

int main()
{
int N,answer=0;
cin>>N;
for(int i = 1 ; i <= N ; i++)
{
answer = answer + i;
}
cout<<answer;
}

Why isn’t this code running

It was just one comment before that I mentioned the answer. Please try to read earlier threads and comments before posting your code blindly @invincible_a99

Also, Please format your code next time :slight_smile:

Thanks