Try to answer bonus question

2 vues (au cours des 30 derniers jours)
Raiven Balderas
Raiven Balderas le 7 Fév 2018
Commenté : Birdman le 7 Fév 2018
Screenshot is attached. Comment what the code to the bonus question is. Also provide explanations.

Réponse acceptée

Birdman
Birdman le 7 Fév 2018
Modifié(e) : Birdman le 7 Fév 2018
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 commentaires
Birdman
Birdman le 7 Fév 2018
Use this:
plot((1:numel(primes(n)))+1,primes(n),'-o')
Birdman
Birdman le 7 Fév 2018
It does plot. For instance:
n=10;
plot((1:numel(primes(n)))+1,primes(n),'-o')
and check the attached figure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by