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 件)

KSSV
KSSV 2020 年 6 月 13 日

0 投票

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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops 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