Hi fellas..this is my first post here..I am new to this 'hardcore programming' and all..I came across a problem for which I killed some time..with no fruits..It might be simple,trivial or even 'famous' for you guys..Any assistance is appreciated much.So here it goes..
Given an integer,the problem is to find the prime number combination whose product form the number since any integer can be given as a product of one or more primary numbers..
For eg..for 36,the solution would be 2,2,3,3.
Another thing..a pseudo code or algorithmic description is sufficient..thanks again..

Recommended Answers

All 3 Replies

I would look up prime factorization. That should point you in the right direction.

1) Create an array of prime numbers less than or equal to the given number.
2) If the given number is prime, you're done.
3) If not find the smallest prime number that is a factor of the given number and then find the other factor associated with that prime number.
4) If the associated factor is prime, then you're done.
5) If not repeat the steps 3 and 4.

1) Create an array of prime numbers less than or equal to the given number.
2) If the given number is prime, you're done.
3) If not find the smallest prime number that is a factor of the given number and then find the other factor associated with that prime number.
4) If the associated factor is prime, then you're done.
5) If not repeat the steps 3 and 4.

Thanks man..could have been a bit deeper & clearer though..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.