
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
JavaScript code to find nth term of a series - Arithmetic Progression (AP)
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.
Example
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));
Output
Following is the output in the console −
20
- Related Articles
- C Program for N-th term of Arithmetic Progression series
- C program to find the sum of arithmetic progression series
- If eight times the $8^{th}$ term of an arithmetic progression is equal to seventeen times the $7^{th}$ term of the progression, find the $15^{th}$ term of the progression.
- Count of AP (Arithmetic Progression) Subsequences in an array in C++
- Find the arithmetic progression whose third term is 16 and seventh term exceeds its fifth term by 12.
- Find the term of the arithmetic progression $9, 12, 15, 18, …$ which is 39 more than its 36th term.
- C Program for N-th term of Geometric Progression series
- 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 5, 2, 13 41,...
- Program to find Fibonacci series results up to nth term in Python
- Find the Nth term of the series 9, 45, 243,1377…in C++
- C++ program to Find Nth term of the series 1, 1, 2, 6, 24…

Advertisements