Find the nth term of the given series Last Updated : 07 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Given the first two terms of the series as 1 and 6 and all the elements of the series are 2 less than the mean of the number preceding and succeeding it. The task is to print the nth term of the series. First few terms of the series are: 1, 6, 15, 28, 45, 66, 91, ... Examples: Input: N = 3 Output: 15Input: N = 1 Output: 1 Approach: The given series represents odd positioned numbers in the triangular number series. Since the nth triangular number can easily be found by (n * (n + 1) / 2), so for finding the odd numbers we can replace n by (2 * n) - 1 as (2 * n) - 1 will always result in odd numbers i.e. the nth number of the given series will be ((2 * n) - 1) * n.Below is the implementation of the above approach: C++ // C++ implementation of the approach #include <bits/stdc++.h> using namespace std; // Function to return the nth term // of the given series int oddTriangularNumber(int N) { return (N * ((2 * N) - 1)); } // Driver code int main() { int N = 3; cout << oddTriangularNumber(N); return 0; } Java // Java implementation of the approach class GFG { // Function to return the nth term // of the given series static int oddTriangularNumber(int N) { return (N * ((2 * N) - 1)); } // Driver code public static void main(String[] args) { int N = 3; System.out.println(oddTriangularNumber(N)); } } // This code contributed by Rajput-Ji Python3 # Python 3 implementation of the approach # Function to return the nth term # of the given series def oddTriangularNumber(N): return (N * ((2 * N) - 1)) # Driver code if __name__ == '__main__': N = 3 print(oddTriangularNumber(N)) # This code is contributed by # Surendra_Gangwar C# // C# implementation of the approach using System; class GFG { // Function to return the nth term // of the given series static int oddTriangularNumber(int N) { return (N * ((2 * N) - 1)); } // Driver code public static void Main(String[] args) { int N = 3; Console.WriteLine(oddTriangularNumber(N)); } } /* This code contributed by PrinciRaj1992 */ PHP <?php // PHP implementation of the approach // Function to return the nth term // of the given series function oddTriangularNumber($N) { return ($N * ((2 * $N) - 1)); } // Driver code $N = 3; echo oddTriangularNumber($N); // This code is contributed by Ryuga ?> JavaScript <script> // Javascript implementation of the approach // Function to return the nth term // of the given series function oddTriangularNumber(N) { return (N * ((2 * N) - 1)); } // Driver code let N = 3; document.write(oddTriangularNumber(N)); // This code is contributed by subham348. </script> Output: 15 Time Complexity: O(1) Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Find the nth term of the given series S sakshi_srivastava Follow Improve Article Tags : Mathematical C++ Programs DSA series Practice Tags : Mathematicalseries Similar Reads Find the Nth term of the series 14, 28, 20, 40,..... Given a number N . The task is to find the N-th term in the following series: 14, 28, 20, 40, 32, 64..... Examples: Input : N = 5 Output : 32 Input : N = 6 Output : 64 Approach: Initialize first number with 14.Run a loop from i = 2 to N and do following steps: For Even i, double the previous term. F 5 min read Find Nth term of the series 1, 1, 2, 6, 24... Given a number N. The task is to write a program to find the Nth term in the below series: 1, 1, 2, 6, 24... Examples: Input: 3 Output: 2 For N = 3 Nth term = (N-1)! = 2 Input: 5 Output: 24 Nth term of the series is given by below formula: Nth term = ( N-1)! Below is the required implementation: C++ 3 min read Find Nth term of the series 1, 8, 54, 384... Given a number N. The task is to write a program to find the Nth term in the below series: 1, 8, 54, 384... Examples: Input : 3 Output : 54 For N = 3 Nth term = ( 3*3) * 3! = 54 Input : 2 Output : 8 On observing carefully, the Nth term in the above series can be generalized as: Nth term = ( N*N ) * 4 min read Find Nth term of the series 1, 6, 18, 40, 75, .... Given a number n, the task is to find the n-th term in series 1, 6, 18, 40, 75, ...Example: Input: N = 2 Output: 6 Explanation: 2nd term = (2^2*(2+1))/2 = 6 Input: N = 5 Output: 75 Explanation: 5th term = (5^2*(5+1))/2 = 75 Approach: Nth term = (N^2*(N+1))/2 Implementation of the above approach is g 3 min read Find Nth term of the series 5, 13, 25, 41, 61... Given a number N. The task is to write a program to find the Nth term in the below series: 5, 13, 25, 41, 61... Examples: Input : 3 Output : 25 For N = 3 Nth term = 3*3 + (3+1)*(3+1) = 25 Input : 5 Output : 61 On observing carefully, the Nth term of the given series can be generalised as: Nth term = 3 min read Like