Program to find sum of first n natural numbers | Returns sum of first n natural numbers ; Driver code
function findSum ( n ) { let sum = 0 ; for ( let x = 1 ; x <= n ; x ++ ) sum = sum + x ; return sum ; } let n = 5 ; document . write ( findSum ( n ) ) ;