Project Euler #30: Digit Nth powers

  • + 1 comment

    My sense was to do the following.

    MIN = 2
    MAX = 1000000
    
    
    def compute(value):
        ans = sum(i for i in range(MIN, MAX)
                  if i == power_digit_sum(value, i))
        return str(ans)
    
    
    def power_digit_sum(value, n):
        return sum(int(c) ** value for c in str(n))
    
    
    if __name__ == "__main__":
        value = int(input())
        print(compute(value))