Sum of Series (n^2-1^2) + 2(n^2-2^2) +….n(n^2-n^2)
Program for finding the sum of the nth term of the series (n^2-1^2) + 2(n^2-2^2) + 3(n^2-3^2) + ….n(n^2-n^2)
Examples:
Input : 2 Output :3 Input :5 Output :150
To solve this problem we have the formula ((1/4)*n2*(n2-1)). We can prove the formula using mathematical induction.
Example n = 2
result = ((1/4)*2^2*(2^2-1))
= ((0.25)*4*(4-1))
= ((0.25)*4*3
= 3 ans.
C++
// CPP Program to finding the // sum of the nth series #include <bits/stdc++.h> using namespace std; // function that calculate // the sum of the nth series int sum_series(int n) { int nSquare = n * n; // using formula of the nth term return nSquare * (nSquare - 1) / 4; } // driver function int main() { int n = 2; cout << sum_series(n) << endl; return 0; } |
chevron_right
filter_none
Java
// javaProgram to finding the // sum of the nth series import java.io.*; class GFG { // function that calculate // the sum of the nth series static int sum_series(int n) { int nSquare = n * n; // using formula of the nth term return nSquare * (nSquare - 1) / 4; } // Driver function public static void main (String[] args) { int n = 2; System.out.println( sum_series(n)) ; } } // This article is contributed by vt_m |
chevron_right
filter_none
Python3
# Python 3 Program to finding # the sum of the nth series # function that calculate # the sum of the nth series def sum_series(n): nSquare = n * n # Using formula of the # nth term return int(nSquare * (nSquare - 1) / 4) # Driver function n = 2print(sum_series(n)) # This code is contributed by Smitha Dinesh Semwal |
chevron_right
filter_none
C#
// C# program to finding the // sum of the nth series using System; class GFG { // Function that calculate // the sum of the nth series static int sum_series(int n) { int nSquare = n * n; // Using formula of the nth term return nSquare * (nSquare - 1) / 4; } // Driver Code public static void Main () { int n = 2; Console.Write( sum_series(n)) ; } } // This code is contributed by vt_m |
chevron_right
filter_none
PHP
<?php // PHP Program to finding the // sum of the nth series // function that calculate // the sum of the nth series function sum_series($n) { $nSquare = $n * $n; // using formula of the nth term return $nSquare * ($nSquare - 1) / 4; } // Driver Code $n = 2; echo(sum_series($n)); // This code is contributed by Ajit. ?> |
chevron_right
filter_none
Output:
3
Recommended Posts:
- Sum of the Series 1/(1*2) + 1/(2*3) + 1/(3*4) + 1/(4*5) + . . . . .
- Sum of the series 1 + (1+3) + (1+3+5) + (1+3+5+7) + …… + (1+3+5+7+…+(2n-1))
- Sum of series 1*1*2! + 2*2*3! + ……..+ n*n*(n+1)!
- Sum of series 1*1! + 2*2! + ……..+ n*n!
- Sum of series (n/1) + (n/2) + (n/3) + (n/4) +.......+ (n/n)
- Sum of the series Kn + ( K(n-1) * (K-1)1 ) + ( K(n-2) * (K-1)2 ) + ....... (K-1)n
- Sum of the series 3, 20, 63, 144, ......
- Sum of the series 2 + (2+4) + (2+4+6) + (2+4+6+8) + …… + (2+4+6+8+….+2n)
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ...... + (1+2+3+4+...+n)
- Sum of the Series 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n
- Sum of the series 1.2.3 + 2.3.4 + ... + n(n+1)(n+2)
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n - 1)^2
- Sum of the series 2^0 + 2^1 + 2^2 +.....+ 2^n
- Value of the series (1^3 + 2^3 + 3^3 + ... + n^3) mod 4 for a given n
- N-th term in the series 1, 11, 55, 239, 991,....
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.
Improved By : jit_t

