Find the sum of all the terms in the n | Python 3 implementation to find the sum of all the terms in the nth row of the given series ; function to find the required sum ; sum = n * ( 2 * n ^ 2 + 1 ) ; Driver Code
from math import pow NEW_LINE def sumOfTermsInNthRow ( n ) : NEW_LINE INDENT sum = n * ( 2 * pow ( n , 2 ) + 1 ) NEW_LINE return sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 NEW_LINE print ( " Sum ▁ of ▁ all ▁ the ▁ terms ▁ in ▁ nth ▁ row ▁ = " , int ( sumOfTermsInNthRow ( n ) ) ) NEW_LINE DEDENT