Find nth term of a given recurrence relation | function to return required value ; Get the answer ; Return the answer ; Get the value of n ; function call to print result
function sum ( n ) { let ans = parseInt ( ( n * ( n - 1 ) ) / 2 ) ; return ans ; } let n = 5 ; document . write ( sum ( n ) ) ;