text: Sum of the first N terms of the series 2 , 10 , 30 , 68 , ... . | C # program to find sum of first n terms ; Function to calculate the sum ; Driver code ; number of terms to be included in the sum ; find the Sum
code: using System ; class gfg { public void calculateSum ( int n ) { double r = ( n * ( n + 1 ) / 2 + Math . Pow ( ( n * ( n + 1 ) / 2 ) , 2 ) ) ; Console . WriteLine ( " Sum ▁ = ▁ " + r ) ; } public static int Main ( ) { gfg g = new gfg ( ) ; int n = 3 ; g . calculateSum ( n ) ; Console . Read ( ) ; return 0 ; } }