Average of first n even natural numbers | java implementation to find Average of sum of first n natural even number ; function to find average of sum of first n even numbers ; sum of first n even numbers ; calculating Average ; driver code
import java . io . * ; class GFG { static int avg_of_even_num ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += 2 * i ; return ( sum / n ) ; } public static void main ( String [ ] args ) { int n = 9 ; System . out . print ( avg_of_even_num ( n ) ) ; } }