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