C Program for N-th term of Arithmetic Progression series

Given 'a' the first term, 'd' the common difference and 'n' for the number of terms in a series. The task is to find the nth term of the Arithmetic Progression series.

Arithmetic Progression (AP) is a sequence of numbers where the difference between any two consecutive terms is constant. This constant difference is called the common difference.

For example, if we have first term a = 5, common difference d = 2, and we want to find the 4th term, the series would be: 5, 7, 9, 11. So the 4th term is 11.

Syntax

nth_term = a + (n - 1) * d

Where:

  • a = First term of the AP
  • d = Common difference
  • n = Position of the term to find

Example

Here's a C program to find the nth term of an Arithmetic Progression −

#include <stdio.h>

int nth_ap(int a, int d, int n) {
    // Using formula to find the nth term: a + (n-1)*d
    return (a + (n - 1) * d);
}

int main() {
    // First term
    int a = 2;
    // Common difference
    int d = 1;
    // nth term to find
    int n = 5;
    
    printf("First term (a): %d
", a); printf("Common difference (d): %d
", d); printf("Position (n): %d
", n); printf("The %dth term of AP: %d
", n, nth_ap(a, d, n)); return 0; }
First term (a): 2
Common difference (d): 1
Position (n): 5
The 5th term of AP: 6

How It Works

The program uses the standard AP formula:

  • AP? = a
  • AP? = a + d
  • AP? = a + 2d
  • AP? = a + (n-1) × d

For the example above: 2 + (5-1) × 1 = 2 + 4 = 6

Conclusion

Finding the nth term of an Arithmetic Progression is straightforward using the formula a + (n-1) × d. This approach has O(1) time complexity as it performs a constant number of operations regardless of the value of n.

Updated on: 2026-03-15T12:24:00+05:30

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements