Project Euler #56: Powerful digit sum

  • + 0 comments

    :)

    n = int(input())
    max = 0
    for i in range(n):
        for j in range(n):
            rand = i**j #or pow(i,j)
            a = list(map(int, str(rand)))
            if(sum(a) > max):
                max = sum(a)
    print(max)