 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Pandigital and Pretty Powerful (Posted on 2009-03-23) 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.) Basic computer solution | Comment 2 of 4 | `2 ^ 2 = 4          2 ^ 29 = 53687091218 ^ 3 = 5832      18 ^ 4 = 10497669 ^ 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:

 Search: Search body:
Forums (0)