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

Home > Numbers
Pandigital and Pretty Powerful (Posted on 2009-03-23) Difficulty: 3 of 5
Determine all possible value(s) if a positive integer N such that the two distinct perfect powers of N will together contain each of the decimal digits 0 to 9 exactly once. None of the perfect powers of N can contain any leading zero.

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Basic computer solution | Comment 2 of 4 |
2 ^ 2 = 4          2 ^ 29 = 536870912
18 ^ 3 = 5832      18 ^ 4 = 104976
69 ^ 2 = 4761      69 ^ 3 = 328509

An exhausive search was done from n = 2 to n = 99380, the largest number whose square would be under the largest pandigital, 9876543210. Each was tested to a power up to that resulting in that largest pandigital number.

The two numbers were presented lower to higher, otherwise each sum would appear twice.


DEFDBL A-Z
PRINT
ll = LOG(1023456789)
lh = LOG(9876543210#)
FOR n = 2 TO 99380
 lb = LOG(n)
 low = 2
 high = -INT(-lh / lb)
 FOR pwr1 = low TO high
   v1 = INT(n ^ pwr1 + .5)
   vs1$ = LTRIM$(STR$(v1))
   IF LEN(vs1$) < 10 THEN
     good = 1
     FOR i = 1 TO LEN(vs1$) - 1
      IF INSTR(MID$(vs1$, i + 1), MID$(vs1$, i, 1)) > 0 THEN good = 0: EXIT FOR
     NEXT
     IF good THEN
      togo$ = "1023456789"
      FOR i = 1 TO LEN(vs1$)
        ix = INSTR(togo$, MID$(vs1$, i, 1))
        IF ix > 0 THEN
          togo$ = LEFT$(togo$, ix - 1) + MID$(togo$, ix + 1)
        END IF
      NEXT
      IF LEN(togo$) > 1 THEN
        IF LEFT$(togo$, 1) = "0" THEN
          MID$(togo$, 1, 1) = MID$(togo$, 2, 1)
          MID$(togo$, 2, 1) = "0"
        END IF
      END IF
      IF togo$ = "0" THEN GOTO notThis
      low2 = INT(LOG(VAL(togo$)) / lb + .5)

      togoh$ = "9876543210"
      FOR i = 1 TO LEN(vs1$)
        ix = INSTR(togoh$, MID$(vs1$, i, 1))
        IF ix > 0 THEN
          togoh$ = LEFT$(togoh$, ix - 1) + MID$(togoh$, ix + 1)
        END IF
      NEXT
      high2 = -INT(-LOG(VAL(togoh$)) / lb + .5)

      FOR pwr2 = low2 TO high2
        v2 = INT(n ^ pwr2 + .5)
        vs2$ = LTRIM$(STR$(v2))
        vAll$ = vs1$ + vs2$
        IF LEN(vAll$) = 10 THEN
          good2 = 1
          FOR i = 1 TO 9
            IF INSTR(MID$(vAll$, i + 1), MID$(vAll$, i, 1)) > 0 THEN
               good2 = 0: EXIT FOR
            END IF
          NEXT
          IF good2 THEN
           IF pwr2 >= pwr1 THEN
            PRINT n; "^"; pwr1; "="; v1; TAB(20); n; "^"; pwr2; "="; v2: ct = ct + 1
           END IF
          END IF
        END IF
      NEXT
notThis:
     END IF
   END IF
 NEXT
NEXT
PRINT ct

 


  Posted by Charlie on 2009-03-23 11:54:31
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 (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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