Find GCD of factorial of elements of given array | Implementation of factorial function ; Function to find GCD of factorial of elements from array ; find the minimum element of array ; return the factorial of minimum element ; Driver Code
< ? php function factorial ( $ n ) { return ( $ n == 1 $ n == 0 ) ? 1 : factorial ( $ n - 1 ) * $ n ; } function gcdOfFactorial ( $ arr , $ n ) { $ minm = $ arr [ 0 ] ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) $ minm = $ minm > $ arr [ $ i ] ? $ arr [ $ i ] : $ minm ; return factorial ( $ minm ) ; } $ arr = array ( 9 , 12 , 122 , 34 , 15 ) ; $ n = count ( $ arr ) ; echo gcdOfFactorial ( $ arr , $ n ) ; ? >