Sum of all the numbers in the Nth row of the given triangle | C # implementation of the approach ; Function to return the sum of the nth row elements of the given triangle ; Driver code
using System ; class GFG { static int getSum ( int n ) { return ( ( n - 1 ) + ( int ) Math . Pow ( n , 2 ) ) ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( getSum ( n ) ) ; } }