Problem 56

completed December 11, 2011

Comments

Using the decimal module in Python, this problem was pretty simple.

Code

import re
def num2str(n):
	return re.split('_', re.sub('\B', '_', str(n)))

import decimal
decimal.getcontext().prec = 200

biggest = 0
for a in range(1, 100):
	for b in range(1, 100):
		ab = map(int, num2str(pow(decimal.Decimal(a), decimal.Decimal(b))))
		ab = sum(ab)
		if ab > biggest: biggest = ab

print biggest