multiplicand

I wanted to know how I would write this program:
Input an unsigned positive number.
Output all numbers that make that number, for example:

Input: 4
1 * 4
2 * 2
4 * 1
Brutefore/recursion would probably be the easiest solution I can't really think of any other off the top of my head.

What I would do is
1) find the smallest factor (ignoring 1 since 1 x 1 x 1.. == 1) after the last smallest
2) find what it needs to multiply by to equal the number
3) find factors of the number found on step 2
4) return to step 1 though you'll have to stop before repeats


so lets look at 100 the smallest factor is 2 and it needs to multiply by 50 for 100 so that'll be the starting number

2 x 50
2 x 2 x 25
2 x 2 x 5 x 5
4 x 25
4 x 5 x 5
Topic archived. No new replies allowed.