Problem 156. Parasitic numbers
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
-
5 Comments
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?
There is 4, not 5
I mis-typed. 4 x 142857 = 571428, which is a shift right of 2. Incidentally, both n = 4 and 5 both make parasitic pairs with 142857.
Thus it is not a 4-parasitic number. It doesn't meet the definition. Nevertheless is a great example of a cyclic number. You can get different cyclic permutations when multiply 142857 by 1, 2, 3, 4, 5 and 6. For 5 you got shift by one digit, therefore it's 5-parasitic.
Ahhh, I see! Thanks, Jan - I get it now!
-
1 Comment
Not actually a general solution. Takes advantage of limited test cases.
Problem Recent Solvers275
Suggested Problems
-
Select every other element of a vector
28085 Solvers
-
3676 Solvers
-
Program an exclusive OR operation with logical operators
691 Solvers
-
367 Solvers
-
341 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!