Pregunta

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?

¿Fue útil?

Solución

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]))
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top