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" |