Can any one tell me the formula to find all the divisors of a number in an excel sheet
Can any one tell me the formula to find all the divisors of a number in an excel sheet
Hi, ans welcome to the forum
The following UDF would be one way
Enter![]()
Please Login or Register to view this content.
Formula:
Please Login or Register to view this content.
where A1 contains your number
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star iconbelow the post.
What version of excel are you using?
This requires Excel 2007 or later.
Data Range
A B C D E F G H I J K 1 Number Divisors 2 27 1 3 9 27 3 82 1 2 41 82 4 13 1 13 5 100 1 2 4 5 10 20 25 50 100 6 ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
This array formula** entered in B2:
=IFERROR(SMALL(IF(MOD($A2,ROW(INDIRECT("1:"&$A2)))=0,ROW(INDIRECT("1:"&$A2))),COLUMNS($B2:B2)),"")
** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
Copy down as needed then across until you get blanks.
Biff
Microsoft MVP Excel
Keep It Simple Stupid
Let's Go Pens. We Want The Cup.
If I understand the proposed code/formula, these look like basic "trial division" algorithms for factorization, which would work very well for small numbers like Tony Valko lists in his example. If you want to explore faster and more efficient algorithms (if your end goal is to factor much larger integers), you might want to do a little research into the Sieve of Eratosthenes (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes ) or Wheel factorization (https://en.wikipedia.org/wiki/Wheel_factorization ) or any of the other prime factorization algorithms ( https://en.wikipedia.org/wiki/Integer_factorization ). Your question is not specifically limited to prime factors. Non-prime factors would be different combinations of the prime factors, so these prime factorization algorithms could make a good starting point.
Originally Posted by shg
Thank you all for the reply, It was useful
You're welcome. We appreciate the feedback!
If your question has been solved please mark the thread as being solved.
In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks