Problem 44749. Exponents in Factorials(hard)
This is problem is a harder version of "Problem 44747. Exponents in Factorials". https://ww2.mathworks.cn/matlabcentral/cody/problems/44747
It's time to get excited about numbers!!! Well, we're just dealing with factorials here, but it's still a good reason to get excited. You're given two numbers, n and k. Calculate the highest exponent of k that could appear in n!
For example, for n=5 and k=2, you're looking for the highest exponent of 2 that could appear in 5!, or 120. The highest power of 2 that evenly divides 120 is 3 (2^3 evenly divides 120, while 2^4 does not) so your output for maxexp(5,2)=3.
You can assume that both n and k are both integers greater than 1. 1<=n<=1e9, 2<=k<=100.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers9
Suggested Problems
-
30004 Solvers
-
Convert a numerical matrix into a cell array of strings
2371 Solvers
-
Find the maximum number of decimal places in a set of numbers
3369 Solvers
-
Split a string into chunks of specified length
2048 Solvers
-
Change the sign of even index entries of the reversed vector
636 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!