Hello everyone, I would like to write a function to find the prime number from 0 to n . I would apreciate your help!

3 5 7......n

5 commentaires

oh yes of course, I will correct this mistake .. thank you
(Volunteers, please do not post complete code for this question, as it is an introductory programming question designed to help people learn how to think about programming. Making mistakes and learning how to debug is an important part of this task that would not be learned if code is given.)

Connectez-vous pour commenter.

Réponses (2)

p = @(n) primes(n);

2 commentaires

I want to write another function by using m-file,if,for,break .....not call the available one.. thank you
you can take a peek at the primes function
edit primes

Connectez-vous pour commenter.

Look in the internet for "sieve of Eratosthenes". You will find smart algorithms which can be implemented in Matlab directly.

Catégories

En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by