Problem 49778. Determine whether a number is a prime self number
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
J.R.! Menzinger
on 4 Aug 2021
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)
ChrisR
on 28 Aug 2021
Thanks for pointing that out. I've made the change.
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
107357 Solvers
-
How to find the position of an element in a vector without using the find function
2762 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1936 Solvers
-
convert matrix to single column
420 Solvers
-
How many unique Pythagorean triples?
147 Solvers
More from this Author306
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!