Prime number function Help!

Hi I am trying to write a code that takes in a vector of doubles and return only prime numbers. I understand I can do this by using isprime() function but I want to try it wo using that function. Could you show me how to do it by using loops?

回答(1 个)

If A is your array,
iwant = A(isprime(A))

2 个评论

I am not trying to use isprime function!
This is discussed lot of times.....you search in mathworks google. You will get many links.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

提问:

2020-6-13

评论:

2020-6-13

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by