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.
using namespace std;
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