Biggest Power Digit Sum

Powers can grow into huge numbers very quickly, but sometimes the interesting part is the sum of their digits. Write a function max_powerful_digit_sum that checks values of a^b where both a and b are less than n. Find the largest digit sum among them. Return that maximum.

Примеры

Ввод
100
Вывод
972
Ввод
10
Вывод
45
Ввод
5
Вывод
13

Нужно реализовать

def max_powerful_digit_sum(n: int) -> int:

Теги

math
PostgreSQLv16

Тук ще се появи резултатът от изпълнението на кода

Visible tests
1
Input
100
Expected972
2
Input
10
Expected45
3
Input
5
Expected13
4
Input
2
Expected1
5
Input
99
Expected970
6
Input
0
Expected0
Focus radio
Paused · SomaFM · Fluid