Answers for "Given the first 2 terms A and B of an Arithmetic Series, tell the Nth term of the series."

0

Given the first 2 terms A and B of an Arithmetic Series, tell the Nth term of the series.

#include <stdio.h>
int nth_ap(int a, int d, int n) {
   // using formula to find the
   // Nth term t(n) = a(1) + (n-1)*d
   return (a + (n - 1) * d);
}
//main function
int main() {
   // starting number
   int a = 2;
   // Common difference
   int d = 1;
   // N th term to be find
   int n = 5;
   printf("The %dth term of AP :%d\n", n, nth_ap(a,d,n));
   return 0;
}
Posted by: Guest on April-17-2021

Code answers related to "Given the first 2 terms A and B of an Arithmetic Series, tell the Nth term of the series."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language