!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

using namespace std;

int main()
int N,answer=0;
for(int i = 1 ; i <= N ; i++)
answer = answer + i;

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: