Try to answer bonus question

2 次查看(过去 30 天)
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