I’m trying to solve ADDNATRL by sum of arithmetic progression approach but i’m getting wrong answer.

**Sum of n terms of AP = n/2[2a + (n – 1)d]**

I’m trying to solve ADDNATRL by sum of arithmetic progression approach but i’m getting wrong answer.

**Sum of n terms of AP = n/2[2a + (n – 1)d]**

Your formula is correct but the code is still giving wrong answer for very big values of N, because of floating point precision limit in Python.

One easy way to get around this is to not deal with floating point at all. Note that you are dealing with floating point because you are doing `N/2`

which gives result in decimals.

To ignore floating point calculation, you can instead use this value of **formula**: `(n * (a + (n_1 * d)))//2`

.