+ Reply to Thread
Results 1 to 7 of 7

Outputting factors and prime factors of number into one cell

  1. #1
    Registered User
    Join Date
    07-17-2009
    Location
    Bristol England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Outputting factors and prime factors of number into one cell

    Hi, I've been trying to produce the factors of a number into a single cell. I have found the one for outputting them into a column, but need a few thousand, so cant have it in this format. I need randbetween(1,100) in column A and the factors in B. So A1=12 B1=1,2,3,4,6,12. The commas don't necessarily need to be there.

    I also will need in the next step produce Prime factors in one single cell. Eg A1=12 B1=2, 2, 6

    Sorry if it's been asked before, but I've had a search and can't quite find what I need.

    Thanks in advance!
    Last edited by Geomarsh; 07-31-2009 at 07:42 AM. Reason: Extra question!

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,676

    Re: Outputting prime factors of number into one cell

    1,2,3,4,6 and 12 are all the factors, not the prime factors. Which one do you need?

  3. #3
    Registered User
    Join Date
    07-17-2009
    Location
    Bristol England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Outputting prime factors of number into one cell

    Sorry. I need all the factors.

    But thinking about it, I will need Prime factors also in the same format in the not too distant future so if you know a way to do either that would be great!

    Thanks
    Last edited by Geomarsh; 07-31-2009 at 07:31 AM.

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,677

    Re: Outputting factors and prime factors of number into one cell

    Put this in a code module:
    Please Login or Register  to view this content.
    If A1 contains 123331060025819, then =Factors(A1) returns 113,12517,87195439
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    07-17-2009
    Location
    Bristol England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Outputting factors and prime factors of number into one cell

    Ok, Sorry but I'm a bit of a novice when it comes to this, but I have opened my macros screen thing, copied n pasted the code. Now what do I do? I used a bit of initiative and found the =isprime so typed that into the cell, but it just come out as 'true' or 'false' not with the actual factors.

    Thanks very much!
    Last edited by Geomarsh; 07-31-2009 at 10:47 AM.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,580

    Re: Outputting factors and prime factors of number into one cell

    Alt F11 is the shortcut. Then insert a module and paste it in.

    Nice code, shg!
    ChemistB
    My 2

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    07-17-2009
    Location
    Bristol England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Outputting factors and prime factors of number into one cell

    Ok found the right function, works great!!

    Any way to get all factors out not just Prime Factors?

    Also, is there any way to output these factors (prime and otherwise) into different cells in the same row?

    eg A1=12 B1=2 C1=2 D1=2 E1=3

    Im learning loads, Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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