project-euler/056_powerful_digit_sum.py

24 lines
439 B
Python

#!/usr/bin/env python3
def power(x):
#brute force, ni glih nek algo.. jbg, deluje
a=2
maxim=0
while a<x:
b=1
while b<x:
k=sum(digitize(a**b))
if k>maxim:
maxim=k
b+=1
a+=1
return maxim
def digitize(x):
if x<10:
return [x]
return [x%10]+digitize(x//10)
if __name__ == '__main__':
print(power(100))