• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Finding what is the smallest divisor, with the remainder will be zero.

Hello friends,

I am looking for a formula to smallest divisor, with the remainder will be zero.

Thank you !
Hi,

Have a look at your workbook, the formula is this ARRAY formula

=SMALL(IF(MOD(A2,ROW(INDIRECT("A2:A"&A2)))=0,ROW(INDIRECT("A2:A"&A2))),1)

B.T.W. I disagree about 5 being the smallest factor of 45, it's 3. Well really it's 1 but you want to ignore 1<g>


This is an array formula which must be entered by pressing CTRL+Shift+Enter
and not just Enter. If you do it correctly then Excel will put curly brackets
around the formula {}. You can't type these yourself. If you edit the formula
you must enter it again with CTRL+Shift+Enter.
 

Attachments

Hi Mike,

I want to avoid volatile functions like INDIRECT ,Is your wonderful solution possible, with INDEX function ?

Thanks for the help !

David
 
Firstly, There is nothing wrong with the Indirect Function

But it can be replaced with the Offset function
=SMALL(IF(MOD(A2,ROW(OFFSET($A$2,,,A2)))=0,ROW(OFFSET($A$2,,,A2))),1) Ctrl+Shift+Enter


and it can also be replaced with the Index function
=SMALL(IF(MOD(A2,ROW($A$2:INDEX($A:$A,A2)))=0,ROW($A$2:INDEX($A:$A,A2))),1) Ctrl+Shift+Enter

The 3 functions are shown in the following file:
 

Attachments

Last edited:
Can't we omit INDIRECT/OFFSET/INDEX at all?

=MIN(IF(MOD(A2,ROW($A$2:$A$100))=0,ROW($A$2:$A$100)))

This is also working!
 
Hi ,

Prime number theory says that you need to check only up to the square root of a number ; if there are no divisors , then the number is prime.

This is useful if you have to check large numbers.

See the attached file.

Narayan
 

Attachments

Back
Top