integer which displays primes

(C++) hi, hope someone can help. I was hoping somone can give me an example of how to write a program that prompts the user to enter an integer which then displays that integer as a product of its primes. eg. 420 will be displayed as 2x2x3x5x7. i have managed to do it without vector but with vector will be brill.
thanks
Well, you can run a for-loop from 2 to the square-root of the number rounded down to the nearest integer.

If the number is divisible by the number your for-loop is on, divide the user-number, then re-run the loop again with that same for-loop number until it is no longer a divisor. Every time you find a divisor, output it to the screen.

Bonus: After '2' goes to '3' in the for-loop, add some code to make the increment occur by two so you can go from '3' to '5' to '7'...

Post what you have after using these hints.
Topic archived. No new replies allowed.