Bob Phillips wrote...
Here is a routine originally presented by Myrna Larson that I use to test
for primes.
=IsPrime(num)
....
Picky: 1 isn't a prime number any more. See
http://mathworld.wolfram.com/PrimeNumber.html
Next a udf implementing the sieve of Eratosthenes is nice but slow.
Since your udf only handles long integers, the largest possible factor
is
INT(SQRT(2^31-1))
or 46340, which is comfortably less than Excel's max row count (at
least for XL97 and subsequent). So a simple worksheet formula would
suffice.
=SUMPRODUCT(--(MOD(N,ROW(INDIRECT("2:"&INT(SQRT(N)))))=0))=0
That's inefficient. It can be speeded up at the cost of complexity.
=OR(N={2;3;5;7},IF(AND(N10,MOD(N,2)=1),
SUMPRODUCT(--(MOD(N,1+2*ROW(INDIRECT("1:"&INT(SQRT(N)/2))))=0))=0))
If the OP or anyone else needs to check larger numbers, there are much
better tools to use than Excel or VBA.