Statistics

Problem Statement for "Numbers"

Problem Statement

Class name: Numbers
Method name: biggestPower
Parameters: int, int
Returns: String


Method signature: String biggestPower(int n, int p)  (be sure your method is
declared public)


Implement a class Numbers, which contains a method biggestPower.


biggestPower returns a String representing the largest positive power of p that
divides
n factorial with a remainder of zero.  Where factorial is the product of all
the positive integers
less than or equal the given number.



* n is between 1 and 15, inclusive
* p is between 2 and 100000, inclusive


Example:


n = 5, p = 2


5! = 120


2 ^ 0 = 1 divides 120 (120 / 1 = 120)
2 ^ 1 = 2 divides 120 (120 / 2 = 60)
2 ^ 2 = 4 divides 120 (120 / 4 = 30)
2 ^ 3 = 8 divides 120 (120 / 8 = 15)
2 ^ 4 = 16 does not divide 120, so return "3" (2 ^ 3 = 8)




Examples:


n = 1, p = 2   returns  "0"
n = 3, p = 6   returns  "1"
n = 10, p = 7  returns  "1"
n = 9, p = 3   returns  "4"

Definition

Class:
Numbers
Method:
biggestPower
Parameters:
int, int
Returns:
String
Method signature:
String biggestPower(int param0, int param1)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: