Program to find the sum of the series 23+ 45+ 75+….. upto N terms
Given a number N, the task is to find the Nth term of the below series:
23 + 45 + 75 + 113 + 159 +…… upto N terms
Examples:
Input: N = 4
Output: 256
Explanation:
Nth term = (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6
= (2 * 4 * (4 + 1) * (4 * 4 + 17) + 54 * 4) / 6
= 256
Input: N = 10
Output: 2180
Approach:
The Nth term of the given series can be generalized as:

Sum of first n terms of this series:

Therefore, Sum of first n terms of this series: ![]()
Below is the implementation of the above approach:
C++
// CPP program to find sum // upto N-th term of the series: // 23, 45, 75, 113... #include <iostream> using namespace std; // calculate Nth term of series int findSum(int N) { return (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6; } // Driver Function int main() { // Get the value of N int N = 4; // Get the sum of the series cout << findSum(N) << endl; return 0; } |
chevron_right
filter_none
Java
// Java program to find sum // upto N-th term of the series: // 23, 45, 75, 113... import java.util.*; class solution { static int findSum(int N) { //return the final sum return (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6; } //Driver program public static void main(String arr[]) { // Get the value of N int N = 4; // Get the sum of the series System.out.println(findSum(N)); } } |
chevron_right
filter_none
Python3
# Python3 program to find sum # upto N-th term of the series: # 23, 45, 75, 113... # calculate Nth term of series def findSum(N): return (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6 #Driver Function if __name__=='__main__': #Get the value of N N = 4 #Get the sum of the series print(findSum(N)) #this code is contributed by Shashank_Sharma |
chevron_right
filter_none
C#
// C# program to find sum // upto N-th term of the series: // 23, 45, 75, 113... using System; class GFG { static int findSum(int N) { //return the final sum return (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6; } // Driver Code static void Main() { // Get the value of N int N = 4; // Get the sum of the series Console.Write(findSum(N)); } } // This code is contributed by Raj |
chevron_right
filter_none
PHP
<?php // PHP program to find sum // upto N-th term of the series: // 23, 45, 75, 113... // calculate Nth term of series function findSum($N) { return (2 * $N * ($N + 1) * (4 * $N + 17) + 54 * $N) / 6; } // Driver Code // Get the value of N $N = 4; // Get the sum of the series echo findSum($N); // This code is contributed // by anuj_67 ?> |
chevron_right
filter_none
Output:
256
Time Complexity: O(1)
Recommended Posts:
- Find the sum of series 3, -6, 12, -24 . . . upto N terms
- Find sum of the series ?3 + ?12 +......... upto N terms
- Find the sum of series 0.X + 0.XX + 0.XXX +... upto k terms
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ..... upto n terms
- Find sum of the series 1+22+333+4444+...... upto n terms
- Find the sum of the series 1+11+111+1111+..... upto n terms
- Sum of the series 0.7, 0.77, 0.777, ... upto n terms
- Sum of the series (1*2) + (2*3) + (3*4) + ...... upto n terms
- Sum of series 2/3 - 4/5 + 6/7 - 8/9 + ------- upto n terms
- Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + - - - - - - upto n terms.
- Find n terms of Fibonacci type series with given first two terms
- Program to get the Sum of series: 1 - x^2/2! + x^4/4! -.... upto nth term
- Program for sum of cosh(x) series upto Nth term
- Program to print the series 2, 1, 4, 3, 6, 5, .... up to N terms
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



