Program to find sum of first n natural numbers | Efficient JAVA program to find sum of first n natural numbers . ; Returns sum of first n natural numbers ; Driver code
import java . io . * ; class GFG { static int findSum ( int n ) { return n * ( n + 1 ) / 2 ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . println ( findSum ( n ) ) ; } }