Prime number function Help!

2 次查看(过去 30 天)
gmltn1212
gmltn1212 2020-6-13
评论: KSSV 2020-6-13
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 个)

KSSV
KSSV 2020-6-13
If A is your array,
iwant = A(isprime(A))
  2 个评论
gmltn1212
gmltn1212 2020-6-13
I am not trying to use isprime function!
KSSV
KSSV 2020-6-13
This is discussed lot of times.....you search in mathworks google. You will get many links.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by