Prime number function Help!

3 visualizzazioni (ultimi 30 giorni)
gmltn1212
gmltn1212 il 13 Giu 2020
Commentato: KSSV il 13 Giu 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?

Risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by