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?

Answers (1)

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

2 Comments

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

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 13 Jun 2020

Commented:

on 13 Jun 2020

Community Treasure Hunt

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

Start Hunting!