Try to answer bonus question

조회 수: 2 (최근 30일)
Raiven Balderas
Raiven Balderas 2018년 2월 7일
댓글: Birdman 2018년 2월 7일
Screenshot is attached. Comment what the code to the bonus question is. Also provide explanations.

채택된 답변

Birdman
Birdman 2018년 2월 7일
편집: Birdman 2018년 2월 7일
By using primes built in function of MATLAB:
function y=prime_count(n)
y=numel(primes(n));
plot(primes(n))
end
From command line:
prime_count(10)
>> 4
  댓글 수: 3
Birdman
Birdman 2018년 2월 7일
Use this:
plot((1:numel(primes(n)))+1,primes(n),'-o')
Birdman
Birdman 2018년 2월 7일
It does plot. For instance:
n=10;
plot((1:numel(primes(n)))+1,primes(n),'-o')
and check the attached figure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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