Question

I know I can find prime numbers less than or equal to 25 using the primes function:

p = primes(25)
p=2    3    5    7   11   13   17   19   23

But how can I find numbers that aren't prime?

Était-ce utile?

La solution

You could do it a number of different ways.

Here's two approaches

a = setdiff([1:25],primes(25))

OR

a = find(~isprime([1:25]))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top