# Find Nth term of the series 1^3/1+(1^3+2^3)/(1+3)+(1^3+2^3+3^3)/(1+3+5)+…

• Last Updated : 16 Aug, 2022

Given a positive integer N. The task is to find Nth term of the series: Examples:

Input: N = 2
Output: 2.25

Input: N = 3
Output: 4

Approach:

From the given series, find the formula for Nth term:

1st term = 1^3/1 = 1/1 = 1

2nd term = (1^3+2^3)/(1+3) = (1+8)/4 = 9/4 = 2.25

3rd term = (1^3+2^3+3^3)/(1+3+5) = (1+8+27)/9 = 4

4th term = (1^3+2^3+3^3+4^3)/(1+3+5+7) = (1+8+27+64)/16 = 6.25

.

.

Nth term = ((N*(N+1)/2)^2)/(N*(2+(N-1)*2)/2) = (N+1)^2/4 = (N^2+2N+1)/4

Derivation:

For the series- Nth term can be written as- Here, and 1+3+5+….+(2*N-1) are in A.P.  Rewriting the above equation using the formula for A.P. as-      The Nth term of the given series can be generalized as: Illustration:

Input: N = 2
Output: 2.25
Explanation: (1^3+2^3)/(1+3)
= (1 +8)/4
= 9/4
= 2.25

Below is the implementation of the above problem:

## C++

 // C++ program to find N-th term // in the series #include  using namespace std;   // Function to find N-th term // in the series double nthTerm(int N) {     return (pow(N, 2) +              2 * N + 1) / 4; }   // Driver Code int main() {     // Get the value of N     int N = 5;     cout << nthTerm(N);     return 0; }

## Java

 // Java code for the above approach import java.io.*; class GFG {       // Function to find N-th term     // in the series     static double nthTerm(int N)     {         return (Math.pow(N, 2) + 2 * N + 1) / 4;     }     public static void main(String[] args)     {         // Get the value of N         int N = 5;           System.out.println(nthTerm(N));     } }   // This code is contributed by Potta Lokesh

## Python

 # python 3 program for the above approach import sys   # Function to find N-th term # in the series def nthTerm(N):       return (pow(N, 2) + 2 * N + 1) / 4   # Driver Code if __name__ == "__main__":              N = 5      print(nthTerm(N))       # This code is contributed by hrithikgarg03188

## C#

 // C# program to find N-th term // in the series using System; class GFG {     // Function to find N-th term   // in the series   static double nthTerm(int N)   {     return (Math.Pow(N, 2) +              2 * N + 1) / 4;   }     // Driver Code   public static void Main()   {       // Get the value of N     int N = 5;     Console.Write(nthTerm(N));   } }   // This code is contributed by Samim Hosdsain Mondal.

## Javascript

 

Output

9

Time Complexity: O(1)

Auxiliary Space: O(1)

My Personal Notes arrow_drop_up
Recommended Articles
Page :