I have a series P[K] is a set of first K prime numbers.

[2,3,5,7,11,…] respectively.

We have two inputs:

Input1: D, which is a sum of different repeated prime number

Input2: K, is given to us

Example 1:

Input1: 11

input2: 3

Explanation:

As K=3, P[3] ={2,3,5}, there are three elements.

1st Occurence: Element 3: 5 Units

2nd Occurence: Element 2: 3 Units

3rd Occurence: Element 2: 3 Units

Output: 3

Another Example

Example 2:

Input1: 16

Input2: 5

As K=5, P[5] ={2,3,5,7,11}, there are five elements.

Minimum number of occurences: 11x1 & 5x1 => 1+1

Output: 2

Output Specification:

Your function should return minimum number of occurence which can sum up to D ?

I am looking for an algorithm to achieve this.

Could anyone let me know how can I achieve it ?