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?

Was it helpful?

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]))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top