Average of Squares of Natural Numbers | Function to get the average ; Driver Code
function AvgofSquareN ( n ) { return ( ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } var n = 2 ; document . write ( AvgofSquareN ( n ) ) ;