Program to find the Hidden Number | Getting the size of array ; Getting the array of size n ; Solution ; Finding sum of the array elements ; Dividing sum by size n ; Print x , if found
let n = 3 ; let a = [ 1 , 2 , 3 ] ; let i = 0 ; let sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } let x = sum / n ; if ( x * n == sum ) document . write ( x ) ; else document . write ( " " ) ;