What is the largest perfect power (in base ten) that contains no repeated digits?.
The largest exponent would be the one needed make 2^p reach 9876543210--that's log2(9876543210) > 33, so we'll use 34 as the largest exponent. With each exponent we'll raise the base number until we get too large a number. The highest non-repeating-digit result will be reported.
DEFDBL A-Z
FOR pwr = 2 TO 34
b = 2
DO
n = INT(b ^ pwr + .5)
ns$ = LTRIM$(STR$(n))
good = 1
FOR i = 1 TO LEN(ns$) - 1
FOR j = i + 1 TO LEN(ns$)
IF MID$(ns$, i, 1) = MID$(ns$, j, 1) THEN good = 0: EXIT FOR
NEXT
IF good = 0 THEN EXIT FOR
NEXT
IF good THEN
IF n > max THEN max = n: bmax = b: pmax = pwr
END IF
IF n > 9999999999# THEN EXIT DO
b = b + 1
LOOP
NEXT pwr
PRINT bmax; "^"; pmax; "="; max
finds
99066 ^ 2 = 9814072356
Edited on January 26, 2013, 10:24 am
|
Posted by Charlie
on 2013-01-25 16:29:24 |