Average of Squares of Natural Numbers | Java program to get the Average of square of first n natural numbers ; Function to get the average ; Driver Code
import java . io . * ; public class GFG { static float AvgofSquareN ( int n ) { return ( float ) ( ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } static public void main ( String [ ] args ) { int n = 2 ; System . out . println ( AvgofSquareN ( n ) ) ; } }