Problem :

https://www.hackerrank.com/challenges/the-power-sum/problem


My Solution :

#!/usr/bin/env python3

def powerSum(X, N, n):
    a = n**N
    if a == X: return 1
    if a > X: return 0
    return powerSum(X-a, N, n+1) + powerSum(X, N, n+1)


X, N = int(input()), int(input())
result = powerSum(X, N, 1)
print(result)