Find nth term of a given recurrence relation | C # program to find nth term of a given recurrence relation ; function to return required value ; Get the answer ; Return the answer ; Driver code ; Get the value of n ; function call to print result
using System ; class GFG { static int sum ( int n ) { int ans = ( n * ( n - 1 ) ) / 2 ; return ans ; } public static void Main ( ) { int n = 5 ; Console . WriteLine ( sum ( n ) ) ; } }