dp with default values of -1.helper(base, n, x, dp) that returns the number of ways to express n using powers of integers starting from base to n.n is 0, return 1 as we have found a valid combination.base raised to the power x is greater than n, return 0 as we cannot include base in our sum.dp[base][n], return that value.val as base raised to the power x.helper to include base in the sum and to exclude base from the sum.dp[base][n] modulo 10^9 + 7.dp[base][n].helper(1, n, x, dp) to start the recursion from base 1.