All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Supreme Seventy Sum (Posted on 2009-10-30) Difficulty: 3 of 5
Determine the maximum value that is obtained by multiplying together a set of positive integers which are all different and whose sum is 70.

See The Solution Submitted by K Sengupta    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 4 |

DECLARE SUB try (s#)
DEFDBL A-Z
DIM SHARED maxprod, maxnum, maxset(11), prodnow, totnow, numnow, setnow(11)
DIM SHARED ct, ct2

FOR i = 1 TO 70
 numnow = 1
 totnow = i
 prodnow = i
 setnow(1) = i
 try 2
NEXT i

PRINT ct
PRINT maxnum; maxprod
FOR i = 1 TO maxnum
 PRINT maxset(i);
NEXT
PRINT

PRINT ct2

SUB try (s)
 IF totnow = 70 THEN
  ct = ct + 1
  IF prodnow = 68428800 THEN ct2 = ct2 + 1
  IF prodnow > maxprod THEN
    maxnum = numnow
    FOR i = 1 TO maxnum
      maxset(i) = setnow(i)
    NEXT
    maxprod = prodnow
  END IF
 ELSE
  FOR i = setnow(s - 1) + 1 TO 70 - totnow
    numnow = s
    setnow(s) = i
    prodnow = prodnow * i
    totnow = totnow + i
    try s + 1
    totnow = totnow - i
    prodnow = prodnow / i
    numnow = s - 1
  NEXT i
 END IF
END SUB

finds

 29927
 10  68428800
 2  3  4  5  6  8  9  10  11  12
 1
 
indicating:

 29,927 ways of selecting unique integers adding to 70.
 
The maximum product uses  10 integers and that product is 68,428,800.

The integers  2  3  4  5  6  8  9  10  11  12 do this.

There is only 1 way of choosing integers multiplying out to 68,428,800 -- the integers shown.

(The line

  IF prodnow = 68428800 THEN ct2 = ct2 + 1
 
 was added after that maximum was found on a previous run.)


  Posted by Charlie on 2009-10-30 12:28:16
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information