Exponents in Factorials - MATLAB Cody - MATLAB Central

Problem 44747. Exponents in Factorials

Difficulty:Rate

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.

Solution Stats

39.24% Correct | 60.76% Incorrect
Last Solution submitted on Jul 28, 2024

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
2
4
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Physics Image
Physics
  • 18 Problems
  • 13 Finishers

Problem Recent Solvers26

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page