Ok so i have been coding this problem.The problem ">

For a given set of K prime numbers S = {p1, p2, ..., pK}, consider the set of all numbers whose prime factors are a subset of S. This set contains, for example, p1, p1p2, p1p1, and p1p2p3 (among others). This is the set of `homble numbers' for the input set S. Note: The number 1 is explicitly declared not to be a homble number.

Your job is to find the Nth homble number for a given set S. Long integers (signed 32-bit) will be adequate for all solutions.

Input format

Line 1: Two space separated integers: K and N, 1 <= K <=100 and 1 <= N <= 100,000.

Line 2: K space separated positive integers that comprise the set S.

<<

The program works fine up to a point.but when the numbers start to get bigg it crashes with no output.These are the tests i run on it. Test 4 fails miserably. Can someone help me out please. Thanks in advance.

Sample test data and answers supposed to generate:

Test 1

5 50

2 3 11 13 17

Ans: 176

---------------------------------

Test 2

6 1000

2 3 5 11 17 23

Ans: 48114

-------------------------------

Test 3

15 10000

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

Ans: 106856

------------------------------

Test 4

7 28888

2 3 5 11 17 23 31

Ans: 905084928

[code]