On this page
You know where the list starts, where it ends and how much it jumps by. The count should take one line of working, yet it is easy to come out exactly one short. Here is where the formula comes from, why the +1 is there, and a check that catches the slip.
How many terms are in an AP if you know the first and last term?
In NCERT's Class 10 textbook, the nth term of an AP with first term a and common difference d is aₙ = a + (n − 1)d (NCERT Mathematics, Chapter 5: Arithmetic Progressions). The same chapter says that if the AP has m terms, the last term aₘ is sometimes written as l.
So set the last term equal to the nth-term formula and solve for n:
l = a + (n − 1)d
l − a = (n − 1)d
(l − a)/d = n − 1
n = (l − a)/d + 1
Why do you add 1 at the end?
Because (l − a)/d does not count terms. It counts the jumps between them. Going from a to l takes n − 1 steps of size d, so dividing gives you the number of steps, and you need one more to count the term you started on.
An off-by-one error is a logic error where a number differs from its intended value by 1, and a fencepost error is a specific type of it: a straight fence 30 feet long with posts 3 feet apart needs 11 posts, not 10 (Off-by-one error, Wikipedia). Ten is the number of gaps. The posts are your terms.
How does the formula work on NCERT examples?
All of these come from NCERT's Arithmetic Progressions chapter.
Two-digit numbers divisible by 3 (NCERT Example 7). The list is 12, 15, 18, …, 99. Here a = 12, l = 99, d = 3. Then (99 − 12)/3 = 87/3 = 29 gaps, and n = 29 + 1 = 30. The book gets the same 30. If you stop at 29, you have left out either 12 or 99.
7, 13, 19, …, 205 (Exercise 5.2, Question 5(i)). Here a = 7, l = 205, d = 6. Then (205 − 7)/6 = 198/6 = 33, so n = 34.
A decreasing AP: 10, 7, 4, …, −62 (NCERT Example 8). Here d = 7 − 10 = −3. Then (−62 − 10)/(−3) = −72/(−3) = 24, so n = 25. Keep the minus sign on d; a negative count means you dropped it.
The same example then asks for the 11th term from the end. NCERT points out that it is the 15th term, not the 14th. The kth term from the end is term n − k + 1, so 25 − 11 + 1 = 15. It is the same +1 again.
Try these yourself (Exercise 5.2, Questions 13 and 14). How many three-digit numbers are divisible by 7? How many multiples of 4 lie between 10 and 250? First find the real first and last terms: 105 to 994 for the first, and 12 to 248 for the second. Answers: 127 + 1 = 128, and 59 + 1 = 60. For the full method on "between" questions, see how to find multiples of 7 between 100 and 300.
How do you check that your count is not off by one?
Run this four-point check before you move on.
Shrink it. Try the same method on a list you can count on your fingers: 3, 6, 9 gives (9 − 3)/3 = 2, and 2 + 1 = 3 terms. If your method gives 2, it is missing the +1.
Look at n. It must be a positive whole number. If (l − a)/d is a fraction, l is not a term of the AP, the same test NCERT uses to show that 301 is not a term of 5, 11, 17, 23, ….
Match the sign. For a decreasing AP both l − a and d are negative, so their ratio is positive.
Pin down the ends. "Between 10 and 250" does not mean a = 10. Find the first and last terms that actually belong to the list before you use the formula.
Knowing n also speeds up other questions, such as finding the middle term of an AP.
If the slip keeps coming back, look at the method, not just at your care. The Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer, so you can follow each line of the method. If the nth-term formula itself feels shaky, the Fermi Concept Library gives each concept its own lesson and its place in the map.
Next time you divide, say "gaps" out loud, then add the first term back.



