how can i write a script file to find all prime numbers from a given range of numbers?

2 次查看(过去 30 天)
I need to find all prime numbers from 0-n (user input n) and n can be anything from 0 to 100. I want to do this for a range from 0-24, so I want matlab to display all prime numbers from 0-24. I don't know where to start though.

回答(1 个)

the cyclist
the cyclist 2015-9-11
编辑:the cyclist 2015-9-11
N = 100;
primes(N)

类别

Help CenterFile Exchange 中查找有关 Discrete Math 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by