Content of a Polynomial | Function to find the content of the polynomial ; Loop to iterate over the elements of the array ; __gcd ( a , b ) is a inbuilt function for Greatest Common Divisor ; Driver Code ; Function call
function findContent ( arr , n ) { var content = arr [ 0 ] ; for ( var i = 1 ; i < n ; i ++ ) { content = __gcd ( content , arr [ i ] ) ; } return content ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } var n = 3 ; var arr = [ 9 , 6 , 12 ] ; document . write ( findContent ( arr , n ) ) ;