0

Here is a problem in my hand that I need so solve it. It sounds like this: Given a number (between 4 and 30000) x, which is the greatest number that can be written as a product made from numbers that have the sum x.

Example:
For x = 7 the result is 12.
Explanation:
12 = 2 x 3 x 3
7 = 2 + 2 + 3

I do not want to abridge the path for solving the problem and I do not want complete code for this problem. I only need some directions and documentation about the method that I could use in order to solve it.

Edited by catcit: n/a

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by cam875
0

2x3x3 = 18, not 12. I suppose you meant 2x2x3??

Yes, my bad. It`s 2 x 2 x 3.

0

found a major mistake in my previous method so nvm.

Edited by cam875: n/a

0

Ok I think i figured it out now but I could still be wrong anyways here it goes.

Any number > 3 can be represented as the sum of 2's and 3's and combinations of these seem to yield the largest products when the terms are all multiplied together. (could be wrong on that)

So you take the number x and start with the 3's and find out how many times you can subtract a 3. If you arrive with remainder 1 it means you have to go back and instead of taking off of a 3 with a 1 leftover take off 2 2's which is better because 2*2 > 3*1.

If you get a remainder of 1 then the answer is 3^((quotient of x/3)-1) * 2^2
If you get a remainder of 0 then the answer is 3^(x/3)
If youi get a remainder of 2 when x/3 then the answer is the 3^(quotient of x/3) * 2

heres some examples
x = 21
21/3 = 7 rem 0 therefore the answer will be 3^7

x = 22
22/3 = 7 rem 1 therefore we go one back to 6 so we have 3^6 * 2^2

x = 23
23/3 = 7 rem 2 therefore the answer is 3^7 *2

now lets run back to the original x = 7
x = 7
7/3 = 2 rem 1 therefore the answer is 3^1 * 2^2 according to our above rules which is exactly 12. I don't know for sure if this is all correct but it seems to be so correct me if the theory is wrong.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.