View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Tyro[_2_] Tyro[_2_] is offline
external usenet poster
 
Posts: 1,091
Default How to determine the prime numbers?

I put this formula in cell B1. It returns Not Prime for every number entered
in A1. I tried both normal and array. I copied the formula from B1 and
pasted it here.

=IF(SUMPRODUCT(--(MOD(A1,(ROW(INDIRECT("2:"&INT(SQRT(A1))))))=0))," Not
Prime","Prime")

Any ideas why it doesn't work?

"Bernard Liengme" wrote in message
...
No need for VBA this time:
=IF(SUMPRODUCT(--(MOD(A1,(ROW(INDIRECT("2:"&INT(SQRT(A1))))))=0))," Not
Prime","Prime")
must be array-entered (ie with SHIFT+CTRL+ENTER)
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email