+ Reply to Thread
Results 1 to 37 of 37

Need Help in getting Divisors of a Number

  1. #1
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Need Help in getting Divisors of a Number

    Hello,

    Can anyone help, I want to get all the divisors of a number in excel, That number is not constant, it keep changes, I want a formula to get the divisors of the number which updates automatically.

    thanks and Regards

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Need Help in getting Divisors of a Number

    Hi, welcome to the forum

    How would you do this manually, and what would a sample answer look like?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Hi, Thanks

    If A1 = 12, then adjacent cells or A2 to A (N) should show the divisors of the A1,

    and if A1 changes then adjacent cells should also change...

    Thanks and Regads

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    If your number is in A1 then put this in C1 and enter it as an array formula (Cnt + shift + enter) then drag it across say 20 columns. if you want really big numbers you'll need to drag it across more columns AND you'll need to expand the formula to use more columns to work out the divisors

    Please Login or Register  to view this content.
    Last edited by Crooza; 12-27-2015 at 04:26 AM.
    Happy with my advice? Click on the * reputation button below

  5. #5
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    I am getting this message while trying to paste the code in C1, and If I click OK and clicking CTRL+SHIFT+ENTER, nothing happening....Screenshot_31.png, please help

    Now I m getting all 1 s in the cells, Screenshot_32.png
    Last edited by sam_thesupreme; 12-27-2015 at 04:34 AM.

  6. #6
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Now I am getting some result, but I think it is not right, i have to get all the Factors / Divisors of the given numberScreenshot_33.png, I dragged the formula to 50 coloums but numbers are not coming in full

  7. #7
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Hi,

    Got it finally, Thank you....

  8. #8
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    is it possible to get the values in vertical rather than in horizontal...Thanks

  9. #9
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Need Help in getting Divisors of a Number

    Try this amended version of Crooza's formula

    =IFERROR(INDEX(SMALL(IF(MOD($A$1,ROW($A$1:$A$100))=0,ROW($A$1:$A$100),""),ROW($A$1:$A$100)),ROW($A3)-2),"")

    Array entered
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  10. #10
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    I am sorry to say, this following formula worked for me to get all the Divisors, but I wanted it in Vertical...

    =IFERROR(SMALL(IF(MOD($A2,ROW(INDIRECT("1:"&$A2)))=0,ROW(INDIRECT("1:"&$A2))),COLUMNS($B2:B2)),"")

  11. #11
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Quote Originally Posted by sam_thesupreme View Post
    I am sorry to say, this following formula worked for me to get all the Divisors, but I wanted it in Vertical...

    =IFERROR(SMALL(IF(MOD($A2,ROW(INDIRECT("1:"&$A2)))=0,ROW(INDIRECT("1:"&$A2))),COLUMNS($B2:B2)),"")

    Did you try ace_xl's version above?

  12. #12
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    I dont know the version sir, I just found the formula somewhere, and applied it, and it worked, but horizontally, just wanted it to work vertical...
    Thanks

  13. #13
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Ace_xl posted an amended version of my formula just above your post. It changes columns to rows so you can do the same thing. Copy it, enter as array formula by pressing cntr, shift, enter then drag down however many rows you want

    This is the vertical version

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Thank you sir..

  15. #15
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Hello,

    Can I get Divisors / Fractals of a Decimal Value like 120.25 etc.... Thanks and Regards

  16. #16
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Normally factors are integers. So if we used your example above you'd want 0.25 and 481 are factors of 120.25!? What level of fraction are you wanting to go down to? 0.125 and 962 are also factors if you keep going. Where does it end?

  17. #17
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    It should end near 1.0 / 0.5, is it possible sir ?

  18. #18
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need Help in getting Divisors of a Number

    Short version of Crooza's formula from post #13
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Not so short version for decimal values, this will return factors where the number of decimal places is less than or equal to the number of decimal places in the original value.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Note that both of these formula need to be array confirmed as before. The formula for decimals will also work correctly with integers (non-decimal values) so you won't need to change the formula for different values.

  19. #19
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Thanks a lot sir, Its working.... Its great feeling to have your support here...Thank you...

  20. #20
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Hello sir,

    the formula is doing gud, but it is not calculating for some entries which contains 4 digits after decimal.... 281.9072, 845.7216,1691.4432 etc etc....kindly look into this.

    Thanks and Regards

  21. #21
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    It is working upto 6 Digits in total, if 3 Digits after Decimal (like 385.254: its working, but 385.2841 its not working ), its working for number like 3456.12, but not for 3456.124, plzz help

  22. #22
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need Help in getting Divisors of a Number

    With the type of formula required to perform this task, there is a limit to the permissible values, which you have exceeded.

    With no decimal, the limit is 1048576
    With 1 digit after the decimal, the limit is 104857.6
    With 2 digits, the limit is 10485.76
    With 3 digits, the limit is 1048.576
    With 4 digits, the limit is 104.8576
    With 5 digits, the limit is 10.48576

    There is no alternative formula method that I know of that would enable you to work around the limits.

  23. #23
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Its not working for 104.8576 also sir...
    you have mentioned 7 digits in total, but its only working for 6 digits in total

  24. #24
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need Help in getting Divisors of a Number

    104.8576 does work unless you're using a really old version of excel (2003 or older) in which case, the limits would be

    65536
    6553.6
    655.36
    65.536
    6.5536

  25. #25
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    sorry, i mis interpreted the number with the digits.... its working for 104.8576 but not above that if 4 digits...105.8576.... thanks, and I m using Office 2013...

  26. #26
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need Help in getting Divisors of a Number

    What is the highest number of digits you would need to work with (before and after decimal)?

  27. #27
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    I need to work with max 9999 before decimal and 9999 after decimal, Thanks and Regards

  28. #28
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Need Help in getting Divisors of a Number

    What is the divisor of a number with decimals, in your opinion?

  29. #29
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    For Example, 8545.254 gets 8545.254 itself, and 4272.627, 2136.314, 1068.157 etc upto max 0.5 / 0.25

  30. #30
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    for 85.4654
    we get
    0.0001
    0.0002
    42.7327
    85.4654

  31. #31
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Need Help in getting Divisors of a Number

    Thoughts:

    1) We are working with decimals, so we are going to bump up against some of the limitations of computer arithmetic. For example, using the proposed =MOD() function to test for "is this a divisor", =mod(85.4654,0.0001) returns -1.6E-15 when I perform that calculation, which is not "exactly equal to 0" which means the test =MOD(85.4654,0.0001)=0 is going to fail to detect 0.0001 as a divisor of 85.4654. Whatever algorithm you use, it is going to need account for the limitations of binary arithmetic.
    Since I know that there are many integer factorization algorithms out there, I would likely be inclined to multiply my input number by 1E4 and force that result to an integer. Then apply the desired integer factorization algorithm to the problem, then divide the results by 1E4 to recover the original values.

    2) It appears that you will potentially be working with up to 8 digit numbers. Based on a quick look at the proposed formulas, it appears that everyone is focusing on a "trial division" type algorithm. It is an effective algorithms, but it is among the least efficient of factorization algorithms. If it works well enough, then use it, but it might be worth researching other, more efficient factorization algorithms https://en.wikipedia.org/wiki/Intege...ing_algorithms

    3) It might be obvious, but an 8 digit number potentially has a lot of possible divisors/factors. I don't know what the theoretical maximum is, but it could be large.

    I don't know how much of that helps. I suspect that the main problem is in thought 1 -- the limitations and inaccuracies in binary arithmetic. Your problem might work out just fine with existing formulas if you adapt them to account for these inaccuracies ("is ABS(MOD(number, factor))<1E-10" as your logical test instead of "is MOD(number,factor) exactly equal to 0").
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  32. #32
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Hi guys,

    Sorry been asleep but I see you guys have had some good discussion

    I'd simply use this for divisors that are fractions

    =IFERROR($A$2*INDEX(SMALL(IF(MOD($A$1/$A$2,COLUMN($A$3:$CV$3))=0,COLUMN($A$3:$CV$3),""),COLUMN($A$3:$CV$3)),COLUMN(C3)-2),"")

    it requires using A2 cell to set the fraction. say 0.5 or 0.25. if you want to use 0.3333333 enter it into cell A2 as =1/3 so you get the right precision

    Sorry I did it on my original column version. I'm sure you'll work out the logic for the row (vertical) version

  33. #33
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Sorry to say, the above formula is giving Multiplications, not Divisors..
    Thanks and RegardsScreenshot_37.png

  34. #34
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Not sure how you're getting that result with my formula.

    Try some easy ones

    a1= 7.5
    a2 = 0.5

    Results should be 0.5, 1.5, 2.5, 7.5

    If you get this the the formula is right. You can try some bigger examples after that
    Last edited by Crooza; 12-28-2015 at 01:44 AM.

  35. #35
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need Help in getting Divisors of a Number

    The shortened version of Crooza's latest formula, adjusted for vertical use.

    Original value in A1, desired factor in A2, formula in A3 and filled down.

    =IFERROR(A$2*SMALL(IF(MOD(A$1/A$2,ROW(A$1:A$100))=0,ROW(A$1:A$100)),ROWS(A$2:A2)),"")

    Note that this done to return the same results as the original in post #32, I haven't looked at the results it produces. Given the problems we have already encountered when the starting number in A1 exceeds the boundaries that I mentioned in post #22, I think that alternative thinking is required. (see MrShorty's thoughts in post #31).

  36. #36
    Registered User
    Join Date
    12-21-2015
    Location
    ONGOLE
    MS-Off Ver
    2013
    Posts
    32

    Re: Need Help in getting Divisors of a Number

    Hello sir,

    All things sorted out,, Thank you very much for your help.

  37. #37
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Need Help in getting Divisors of a Number

    Great. Glad we got there

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] FORMULA for DIVISORS
    By tejaz007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-28-2015, 05:24 AM
  2. [SOLVED] Macros to mark number in a column, if number is x+10, given previously marked number x.
    By aleem5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2015, 07:49 PM
  3. Replies: 10
    Last Post: 10-30-2013, 07:29 PM
  4. number in cell is number to add number of rows wit copy some contex
    By nicollab in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2012, 08:09 AM
  5. Multiple conditional formatting - overcoming -ve divisors
    By Monkeyfuzzle in forum Excel General
    Replies: 1
    Last Post: 11-15-2011, 12:23 PM
  6. Lookup largest number in a column treating negative number as postive number
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2010, 08:09 AM
  7. Replies: 7
    Last Post: 12-18-2008, 07:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1