- Related Questions & Answers
- Java Program to Find sum of Series with n-th term as n^2 – (n-1)^2
- C/C++ Program to Find the sum of Series with the n-th term as n^2 – (n-1)^2
- C/C++ Program to Find sum of Series with n-th term as n power of 2 - (n-1) power of 2
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2
- C++ program to find the sum of the series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2) in C++
- Sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n in C++
- Python Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Sum of the series 1^1 + 2^2 + 3^3 + ... + n^n using recursion in C++
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n - 1)^2 in C++
- Program to find N-th term of series 1, 2, 11, 12, 21… in C++
- Sum of the series 1.2.3 + 2.3.+ … + n(n+1)(n+2) in C
- Sum of the series Kn + ( K(n-1) * (K-1)1 ) + ( K(n-2) * (K-1)2 ) + ... (K-1)n in C++
- C++ program to find the sum of the series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! + …… n/n!

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below:

We are given an integer input n and we need to sum of all n terms where the n-th term in a series as expressed below −

Tn = n2 - (n-1)_{2}

We have direct formulas for computing the sum which includes the squared muktiolicaion of n which involves more time complexity . To reduce that we usr modular multiplication approach here

Now let's see the implementation −

# Python program to find sum of given # series. mod = 1000000007 def findSum(n): return ((n % mod) * (n % mod)) % mod # main() n = 229137999 print (findSum(n))

218194447

All the variables are declared in the global frame as shown in the figure given below −

In this article, we learned about the approach to Find the sum of Series with the n-th term as n^2 – (n-1)^2

Advertisements