Write a function that takes an integer n and finds the smallest integer m whose factorial is divisible by n. For example, if
, then the smallest factorial that is a multiple of n is 5! = 120; therefore,
.
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers16
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6685 Solvers
-
2034 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
681 Solvers
-
Magic is simple (for beginners)
11137 Solvers
-
I've got the power! (Inspired by Project Euler problem 29)
142 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Chris, please check test 21. The factors of 1535238 include two 67's, therefore it seems to me the solution should be 134.
David: Take another look. ChrisR's anti-lookup trick lets correct solutions pass the test!
David, you are correct for Kempner(1535238), but that test asks for Kempner(Kempner(Kempner(1535238))).
Unfortunately, it does not stop lookup tables since 134 factors to 2 and 67, which means it obtains the same result as a lookup table. Kempner(Kempner(Kempner(1535238))) will do 134 -> 67 -> 67 and a lookup table 67->67->67.
May I suggest using Kempner(Kempner(Kempner(123456787654321))+10) as a test against lookup tables?