I'm trying to bound a series of recursive equations:

EDIT: I made a mistake in the initial post and have updated the equations to reflect that.

f(x) = x - x*2/5

f(x) = x - x*2/5 - x*2/7 + x*4/35

f(x) = x - x*2/5 - x*2/7 - x*2/11 + x*4/35 + x*4/55 + x*4/77 - x*8/385

etc

The first wrinkle comes from the fact that x will always be an integer, and my answer must always be a positive integer. Further the value of every given term (such as -x*2/5) must also be an integer.

For example, if x was 103, then the first equation (-x*2/5) would seem to be -41.

However, the problem comes from the fact that the answers will not be completely evenly spread.

Specifically, if x was 103, then the first equation -(x*2/5) could be -40, -41, or -42. We simply don't know.

My concern comes from the third equation (and later equations, as we continue to get more and more terms in the equation as we continue adding prime numbers). Continuing the example, if x was 103, then:

-x*2/5 could be -40, -41, or -42. -x*2/7 could be -28, -29 or -30. -x*2/11 could be -18, -19 or -20. x*4/35 could be 8, 9, 10, 11 or 12. x*4/55 could be 4, 5, 6, 7 or 8. x*4/77 could be 4, 5, 6, 7 or 8. -x*8/385 could be 0, -1, -2, -3, -4, -5, -6, -7, or -8.

If I simply assume the largest possible answer for each one, then I end up in a situation where my answer is a negative integer (which I know it cannot be). So how do I put a bound on this equation such that I can ensure I'll always get a positive solution?

EDIT: Further explanation and comments:

The next equation would be:

x - x*2/5 - x*2/7 - x*2/11 - x*2/13 + x*4/35 + x*4/55 + x*4/65 + x*4/77 +x*4/91 + x*4/143 - x*8/385 - x*8/455 - x*8/715 - x*8/1001 + x*16/5005

(the first set of terms is -x*2/prime, the second set is +x*4/product of 2 primes, the third set is -x*8/product of 3 primes, etc, noticing that 2, or 4, etc is 2^(the number of primes in the product forming the denominator), and the set is negative or positive based on (-1)^(the number of primes in the product forming the denominator)

The complicated part is exactly the spread. Specifically, let us look at the second equation, and next at the term -x*2/5. For every 5 elements in x, 2 of them are 'bad' elements (thus why we have a minus, and why it is 2/5). Looking at the next term, -x*2/7: For every 7 elements in x, 2 of them are 'bad' elements (again, this results in a minus, and 2/7). The final term, +x*4/35, is to account for the overlap. We've taken out a set of elements based on the first term, and we've taken out a set of elements based on the second term; however, some of these elements are actually the same elements; specifically, 4 out of every 35 elements will be a bad element that falls in both the first (x*2/5) and second (x*2/7) terms, so we have to add that amount back in to balance the equation. As a note, the overlap does exactly show up in these patterns, they are not estimates.

As we add more primes into the equation (and I need this to work for 50,000 primes, which is why I need a bound, and why, as I'll explain in a second, the spread is effectively unpredictable), we have more pairs that cause overlap; but then the overlap of pairs start to overlap themselves, creating the third set of terms (that are the triples), and then those start to overlap (causing the fourth set of terms), etc, etc. With even 10 primes included, this equation becomes completely hopeless to solve using brute force. There are various other equations that are equivalent to this one (and are much easier to manipulate), but first I need to deal with the weird spread you have noticed, so that I can make sure any manipulations I do to the equivalent equations actually account for all the variances that occur in this, the original equation.

The spread problem:

Based on the first term, out of every 5 elements of x, 2 of them are bad elements. Out of every 5 elements, the same two will be bad elements. (So if in the first 5 elements, the first and third elements were bad, then we would know that the 6th and 8th, the 11th and 13th, etc, elements are all bad.) However, the pattern to determine which elements are bad is unique for each prime number (so even if you know which two elements are bad out of every 5 elements, that doesn't help you determine which two elements are bad out of every 7 elements). To make matters worse, for every value of x, you would have to re-determine which elements are bad for each prime number. (So if x = 103, and you somehow determined that out of every 5 elements, the first and third were bad, that would not tell you anything about which elements are bad when x = 104.)

To explain why there is the range: If x = 103, then it is possible that, out of every 5 elements, the first and second elements are bad. Thus, the 101st and the 102nd elements would be bad. In this case, -x*2/5 = -42. However, it is also possible (I haven't actually worked it out), that if x = 103, then out of every 5 elements, the fourth and fifth elements are bad. In this case the 104th and 105th elements would be bad; but those elements are not actually in x. So in this case, -x*2/5 = -40. (And finally, if out of every 5 elements, the 2nd and 4th elements were bad, then -x*2/5 = -41.)

So, given that I need this equation to have a bound based on a large number of primes (hopefully ANY number of primes), and given that x is a free variable, and that the spread is different for every prime number (and therefore every product of prime numbers for the later sets of terms), and that the spread changes for every value of x, I am left with trying to bound it in rather silly fashions.

However, given that all I need is a bound that makes the equation result in a positive integer each time (even if it is only 1), the bound should be possible. I just don't know how to find it.