def calc(x): sum=0 while x>0: sum+=(x%10) x//=10 return sum bigest=-1 for a in range(1,100): for b in range(100): tp=calc(a**b) if tp>bigest: bigest=tp print(bigest)