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

Home > Just Math
Going Maximum with Geometric (Posted on 2011-10-21) Difficulty: 3 of 5
Determine the maximum value of a (base ten) positive integer N (with non leading zeroes) such that each of the digits of N, with the exception of the first digit and the last digit, is less than the geometric mean of the two neighboring digits.

*** For an extra challenge, solve this puzzle without the aid of a computer program.

See The Solution Submitted by K Sengupta    
No Rating

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

Of the 949 such numbers that can't be extended farther on the right or to the left (such as the short 96557 or 75569, for which no possible next--or previous--digit would allow the 7 to continue to be valid), the largest is 95322359, found by:

DECLARE SUB addOn ()
DIM SHARED dig(25), sizeNow, ansCt, maxTot, digMax(25), maxSize

FOR a = 1 TO 9
 dig(0) = a
FOR b = 0 TO 9
 dig(1) = b
 sizeNow = 2
 addOn

NEXT
NEXT
PRINT
PRINT ansCt
FOR i = 0 TO maxSize - 1
  PRINT digMax(i);
NEXT
PRINT

SUB addOn
  IF dig(sizeNow - 2) = 0 THEN
    minDig = 10
  ELSE
    minDig = INT(dig(sizeNow - 1) * dig(sizeNow - 1) / dig(sizeNow - 2) + 1)
  END IF
  IF minDig > 9 THEN
   IF dig(1) * 9 <= dig(0) * dig(0) AND sizeNow >= 3 THEN
    tot = 0
    FOR i = 0 TO sizeNow - 1
       PRINT dig(i);
       tot = tot * 10 + dig(i)
    NEXT i
    PRINT
    IF tot > maxTot THEN
      maxTot = tot
      maxSize = sizeNow
      FOR i = 0 TO sizeNow - 1
        digMax(i) = dig(i)
      NEXT
    END IF
    ansCt = ansCt + 1
   END IF
  ELSE
    FOR newDig = minDig TO 9
      dig(sizeNow) = newDig
      sizeNow = sizeNow + 1
      addOn
      sizeNow = sizeNow - 1
    NEXT
  END IF
END SUB


 


  Posted by Charlie on 2011-10-21 15:09:42
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 (3)
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