- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

We are required to write a JavaScript function that takes in three numbers as argument (first two numbers are supposed to be the starting two consecutive terms of an arithmetic progression).

And the third number, say n, is the 1 index-based element of the series whose value we are required to calculate

For example −

If the input is 2, 5, 7

Then the series will be −

2, 5, 8, 11, 14, 17, 20

And the output should be 20.

Following is the code −

const a = 2, b = 5; const N = 7; const findNthTerm = (first, second, num) => { const diff = second - first; const fact = (num - 1) * diff; const term = first + fact; return term; }; console.log(findNthTerm(a, b, N));

Following is the output in the console −

20

- Related Questions & Answers
- C Program for N-th term of Arithmetic Progression series
- C program to find the sum of arithmetic progression series
- Count of AP (Arithmetic Progression) Subsequences in an array in C++
- C Program for N-th term of Geometric Progression series
- C++ program to find nth term of the series 5, 2, 13 41,...
- C++ program to find Nth term of series 1, 4, 15, 72, 420…
- C++ program to find Nth term of the series 1, 5, 32, 288 …
- C++ program to find Nth term of the series 1, 8, 54, 384…
- C++ program to find Nth term of the series 3, 14, 39, 84…
- C++ program to find Nth term of the series 1, 6, 18, 40, 75, ….
- C++ program to Find Nth term of the series 1, 1, 2, 6, 24…
- C++ program to find Nth term of the series 5, 13, 25, 41, 61…
- C++ program to find Nth term of the series 0, 2, 4, 8, 12, 18…
- Find nth term of a given recurrence relation in C++
- Find nth term of a given recurrence relation in Python

Advertisements