Prime number function Help!

4 Ansichten (letzte 30 Tage)
gmltn1212
gmltn1212 am 13 Jun. 2020
Kommentiert: KSSV am 13 Jun. 2020
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?

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by