Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Finding all divisors of an integer

by gri6507 (Deacon)
on Jul 03, 2004 at 14:08 UTC ( [id://371582]=note: print w/replies, xml ) Need Help??


in reply to Finding all divisors of an integer

Crocodil Gena

This sounds like a homework problem. Yet nonetheless, let me give a shot at answering your question. Basically what you are asking for is an algorithm that finds the smallest prime number a given number is divisible by (except for the multiplicative identity). So, in your case, the smallest prime that 20 is divisible by is 2, giving your a remainder of 10. The smallest prime 10 is divisible by is, again, 2, giving you a remainder of 5. Five, in itself is prime, so you're done.

So, 20 is made up of 2,2,5, and of course the multiplicative identity. Multiplying together the different combinations of the found primes, gives you the factors you were asked to find.

Replies are listed 'Best First'.
Re^2: Finding all divisors of an integer
by pbeckingham (Parson) on Jul 04, 2004 at 16:25 UTC

    That's not at all the question that is being asked, and has nothing to do with primes. OP is asking for factorization all factors of a number.

      This algorithm finds all factors of a number!
      If you multiply all the possible combinations of the prime factors together (and get rid of repeats), you get a list of all the factors, and the number itself. I wonder how you multiply all the possible combinations of a list...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://371582]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found