text: 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
code: def power ( n , r ) : NEW_LINE INDENT count = 0 ; i = r NEW_LINE while ( ( n / i ) >= 1 ) : NEW_LINE INDENT count += n / i NEW_LINE i = i * r NEW_LINE DEDENT return int ( count ) NEW_LINE DEDENT n = 6 ; r = 3 NEW_LINE print ( power ( n , r ) ) NEW_LINE