Power of a prime number ‘ r ’ in n ! | Function to return power of a no . ' r ' in factorial of n ; Keep dividing n by powers of ' r ' and update count ; Driver Code
< ? php function power ( $ n , $ r ) { $ count = 0 ; for ( $ i = $ r ; ( $ n / $ i ) >= 1 ; $ i = $ i * $ r ) $ count += $ n / $ i ; return $ count ; } $ n = 6 ; $ r = 3 ; echo power ( $ n , $ r ) ; ? >