Problem 156. Parasitic numbers
Test whether the first input x is an n-parasitic number: http://en.wikipedia.org/wiki/Parasitic_number. ( n is the second input.)
Examples:
parasitic(128205,4) ---> true
parasitic(179487,4) ---> true
parasitic(179487,3) ---> false
Solution Stats
Problem Comments
-
5 Comments
might be best to add a test case to guard against test suite hacking
Far too few test cases. In fact, a serious issue with this problem is that there are too few parasitic numbers that will fit into even 64 bits for most values of n.
I've added some test cases, that will make it a bit more difficult to game this problem.
Cases 5 and 7 are identical, and I believe they are both wrong. 5 x 142857 = 714285. Isn't this a parasitic number? What am I missing?
Can the problem creator disqualify "solutions" that cheat? There should be a point penalty (-200) associated with cheating too.
Solution Comments
Show commentsProblem Recent Solvers293
Suggested Problems
-
Swap the first and last columns
20438 Solvers
-
Project Euler: Problem 3, Largest prime factor
1430 Solvers
-
Convert a numerical matrix into a cell array of strings
1830 Solvers
-
Are all the three given point in the same line?
415 Solvers
-
Who has power to do everything in this world?
442 Solvers
More from this Author23
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!