Answers for "the power sum"

0

the power sum

def count_expressions(x, n, vals):

    s = sum(v**n for v in vals)

    if s == x:
        return 1
    else:
        v = (if vals.empty() then 1 else (last element of vals) + 1)

        answer = 0
        while s + v**n <= x:
            answer += count_expressions(x, n, vals + [v])
            v++
        return answer
Posted by: Guest on August-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language