Project Euler #56: Powerful digit sum

Sort by

recency

|

32 Discussions

|

  • + 0 comments

    solution python 3

    def digit_sum(number):
        return sum(map(int, str(number)))
    
    def max_digital_sum(n):
        max_sum = 0
        for a in range(1, n):
            for b in range(1, n):
                max_sum = max(max_sum, digit_sum(a**b))
        return max_sum
    
    
    n = int(input())
    print(max_digital_sum(n))
    
  • + 0 comments

    Simple solution in Python 3

    n=int(input().strip())
    m=0
    for i in range(1,n):
        for j in range(1,n):
            s=sum(map(int,list(str(pow(i,j)))))
            if s>m:
                m=s
    print(m)
    
  • + 0 comments

    100/-points python3

    def summer(n):
        '''Takes in an integer n and returns the sum of its digits'''
        return sum([int(x) for x in str(n)])
    
    n=int(input())
    print(max([summer(i**j) for i in range(2,n) for j in range(1,n)]))
    
  • + 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)
    
  • + 1 comment

    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)