OFFSET
1,2
LINKS
Dominic McCarty, Table of n, a(n) for n = 1..237
Dominic McCarty, Log-log scatterplot of first 1000 terms
EXAMPLE
Using exponentiation and concatenation, the digits of 25 can be arranged to yield: 25, 52, 2^5, 5^2. The largest of these is 52, so a(25) = 52.
Using exponentiation and concatenation, the digits of 26 can be arranged to yield: 26, 62, 2^6, 6^2. The largest of these is 2^6, so a(26) = 2^6 = 64.
PROG
(Python)
def a(n):
if n < 10: return n
d = sorted(map(int, list(str(n))))
for q in [1, 0]:
while q in d and (i := d.index(q)) != len(d)-1:
d.pop(i)
d[-1] = (d[-1]*10)+q
for q, r in [(2, 5), (3, 3)]:
if (len(d)) == 1: return d[0]
if d[-2] == q and d[-1] <= r:
d.pop(-2)
d[-1] = (d[-1]*10)+q
for i in range(len(d)-2, -1, -1): d[i] = d[i] ** d[i+1]
return d[0] # Dominic McCarty, Mar 15 2025
CROSSREFS
KEYWORD
nonn,base,nice
AUTHOR
STATUS
approved
