# Project Euler #56: Powerful digit sum

# Project Euler #56: Powerful digit sum

ErikTillema + 0 comments Golden tip for apparently Java users but also for .NET: since we are working base 10, we can use the ToString() method of BigIntegers to get all the digits. It turns out that this is many times faster than using modulo and division repeatly to find all the digits. This changed test case 4 from time-out to accepted for me.

Or you can always precalculate some things of course :-)

mauricepatel37 + 0 comments I have solved it just by writing few lines in python but is there any efficient way to solve this apart from brute force?

tharindukavinda1 + 0 comments my solution in python

# Enter your code here. Read input from STDIN. Print output to STDOUT n= int (input()) #a , b =0 a=0 for i in range ( n ): for j in range (n): p=pow(i,j) #print (p) p=str(p) p=list(p) q=0 for k in range (len(p)): q=q+ int (p[k]) if ( a<q ): a=q print(a)

nikhilachow9 + 0 comments p,l1,h1 = int(input()),[],[] l = p-1 for i in range(1,p): for m in range(1,p):

k = i**m l1.append(k) for i in l1: h1.append(sum([int(h) for h in list(str(i))])) print(max(h1))

bozonych + 0 comments is it possible to solve this problem using js ??

Sort 28 Discussions, By:

Please Login in order to post a comment