GCD of factorials of two numbers | JavaScript program to find GCD of factorial of two numbers . ; Driver program to test above functions
function factorial ( x ) { if ( x <= 1 ) return 1 ; var res = 2 ; for ( i = 3 ; i <= x ; i ++ ) res = res * i ; return res ; } function gcdOfFactorial ( m , n ) { var min = m < n ? m : n ; return factorial ( min ) ; } var m = 5 , n = 9 ; document . write ( gcdOfFactorial ( m , n ) ) ;