Open acha-bill opened 4 years ago
Find the number of ways that a given integer, X , can be expressed as the sum of the Nth powers of unique, natural numbers.
X
Nth
For example, if X = 13 and N = 2, we have to find all combinations of unique squares adding up to 13. The only solution is 2^2 + 3^2.
X = 13
N = 2
2^2 + 3^2
Write a function that given X and N, calculates the number of ways X and be represented as a power sum of N.
N
e.g
x = 10 and n = 2 Answer: 1
explanation: There is only 1 way:
3^2 + 1^2
x = 100, n = 2 answer: 3
explanation: Ther are 3 ways to get 100 as a sum of squares
100^2
6^2 + 8^2
1^2 + 3^2 + 4^2 + 5^2 + 7^2
x = 100, n = 3 answer: 1
There is only 1 way 100 can be expressed as a sum of cubes
1^3 + 2^3 + 3^3 + 4^3
Find the number of ways that a given integer,
X
, can be expressed as the sum of theNth
powers of unique, natural numbers.For example, if
X = 13
andN = 2
, we have to find all combinations of unique squares adding up to 13. The only solution is2^2 + 3^2
.Write a function that given
X
andN
, calculates the number of ways X and be represented as a power sum of N.e.g
explanation: There is only 1 way:
3^2 + 1^2
e.g
explanation: Ther are 3 ways to get 100 as a sum of squares
100^2
6^2 + 8^2
1^2 + 3^2 + 4^2 + 5^2 + 7^2
e.g
There is only 1 way 100 can be expressed as a sum of cubes
1^3 + 2^3 + 3^3 + 4^3