Вопрос

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?

Это было полезно?

Решение

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]))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top