Integers can be classified as generated numbers or self numbers. A generated number is one that can be expressed as the sum of another number and its digit sum. For example, 15 can be written as 12+(1+2); in other words, 15’s generator is 12. A self number cannot be expressed in this way.
Write a function to determine whether a number is a prime self number.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers17
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52693 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1305 Solvers
-
Construct an index vector from two input vectors in vectorized fashion
448 Solvers
-
165 Solvers
-
169 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!
Nice Problem!
but I found remarkable your syntax on test case Nr. 27:
a = arrayfun(@(k) isPrimeSelf(n(k)),1:length(n));
if you use 'arrayfun' you can actually parse the vector directly and you can avoid parsing the indices. The following expression would be more narrow:
a = arrayfun(@isPrimeSelf,n)
Thanks for pointing that out. I've made the change.