30/09/2018, 23:10
[Code Challenge] PrimeSum
A number is called a k-primeSum if it can be represented as a sum of k (not necessarily distinct) prime numbers. Implement a function that checks if the given number is k-primeSum or not.
Example
For n = 9 and k = 3, the output should be
primeSum(n, k) = true.
We can represent 9 as 2 + 2 + 5.
Input/Output
[time limit] 4000ms (js)
[input] integer n
Constraints:
1 ≤ n ≤ 250.
[input] integer k
Constraints:
1 ≤ k ≤ 5.
[output] boolean
true if n is a k-primeSum, false otherwise.
Test 1
Input:
n: 9
k: 3
Output:
Empty
Expected Output:
true
Console Output:
Empty
Test 2
Input:
n: 9
k: 3
Output:
Empty
Expected Output:
true
Console Output:
Empty
Source
Bài liên quan