Program to find sum of first n natural numbers | Efficient CPP program to find sum of first n natural numbers . ; Returns sum of first n natural numbers ; Driver code
#include <iostream> NEW_LINE using namespace std ; int findSum ( int n ) { return n * ( n + 1 ) / 2 ; } int main ( ) { int n = 5 ; cout << findSum ( n ) ; return 0 ; }