Maximum possible GCD for a pair of integers with sum N | Function to find the required GCD value ; If i is a factor of N ; Return the largest factor possible ; If N is a prime number ; Driver code
function maxGCD ( N ) { for ( var i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { return N / i ; } } return 1 ; } var N = 33 ; document . write ( " " + " " + maxGCD ( N ) ) ;