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.
How to find the position of an element in a vector without using the find function
Volume of a Parallelepiped
Replace all zeros and NaNs in a matrix with the string 'error'
Create a vector whose elements depend on the previous element
Find the nearest prime number
Multiply binary numbers
Count unique orderings of vertices of a polygon
Compute the nth term from the Sieve of Flavius Josephus
Identify Ruth-Aaron numbers
Count the square-full divisors of a number
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office