views:

122

answers:

6

Hi all. I was wondering if one can do the following:

We have:

  • X is a product of N-primes, thus I assume unique.
  • C is a constant. We can assure that C is a number that is part of the N-primes or not. Whichever will work best.
  • X mod C = Z

We have Z and C and we know that X was a product of N-primes, where N is restricted lets say first 100 primes.

Is there anyway we can get back X?

A: 

Your question is rather hard to understand, but maybe you want to read about the Chinese Remainder Theorem.

starblue
Can you elaborate please? I don't see how the CRT helps, since you're supposed to take the result modulo multiple numbers there.
IVlad
Sorry, Ja English not my strong suite ! :P"Michael" basically explained it better with he's exampleI have 7 and 1 need to get 15
Piet
+2  A: 

I don't think so. Because C is not part of X, you are losing information when you do the X mod C operation. Further, mod only returns part of an operation and requires div to get the other portion of the result.

Example: (3*5) % 7 = 1. Because you lost information, I don't see any way to get back to 15 from 1 and 7 without the div portion directly. You'd have to start adding up 7s and adding the remainder and comparing to simulate the missing div portion of the equation.

Michael Dorgan
hmm ja that could may be work ? It will take time yes, but you think one would get false positives ?
Piet
False positives? Well, technically you would end up a bunch of values because the value of X would be unknown. In the case of (7*13) % 8 = 3, Z would be 3 and C would be 8. However, if you try to find X using just those two numbers and the finite list of primes that you create, consider (5*7) % 8. X = 5*7 = 35 there, but the result is still the same. In other words, you would never have a single value of X when there is no way to determine what X is reliably. Instead, you would end up with a list for X % 8 = 3, such as 35 (5*7), 91 (7*13), 299 (13*23), etc.
Dustin
Jip saw below :(
Piet
The problem is on the inverse, you don't have X to start with so nothing to compare against - just a linear list of numbers that X could be.
Michael Dorgan
+2  A: 

No. Here is a counter-example:

Suppose X = 105 ( = 3x5x7 ).

Take C = 13 so that X mod C = Z = 1.

However X = 118 ( = 2x59 ) also gives Z = 1 with C = 13.

Troubadour
Bugger !, your right :(
Piet
This isn't a counterexample. He has the equation `X mod C = Z` and he wants to find `X` knowing that it is `a` product of `N` primes. Why does the solution have to be unique?
IVlad
@IVlad: It seemed clear to me the way the question was worded was that there was a definite original value for X.
Troubadour
@IVlad: "Why does the solution have to be unique?" that's what I read "get back X" to mean. As opposed to saying, "find all possible X".
Steve Jessop
Well, I think the question can be interpreted both ways. He said "`X` is a product of `N` unique primes", so I assumed he wants any solution that fits. "Get back `X`" does imply an original value of `X` however.
IVlad
Agreed, I think the question is a bit unclear. It doesn't help that just in general, "inverse" can mean two different things: the actual inverse function (if one exists, i.e. if the original function is bijective), vs. the function which maps elements of the co-domain to their pre-images in the domain (which therefore can give 0 results or more than 1, as in "square root is the inverse of square, and the square roots of 4 are +/- 2"). So there are two potential reasons for failure - because there is no X, or because X isn't unique. In different contexts those may or may not "count" as failure.
Steve Jessop
A: 

We'll need some more info to figure this out for you. For instance, if you mean that X is the product of the first N primes, N <= 100, then brute force search will work for you.

If you mean X the product of some subset of the first 100 primes, then it is harder. You are essentially asking if you can tell whether X is smooth or not given X mod Z. If you could do that, you'd probably be able to improve the best known integer factoring algorithms, as they depend on detecting smooth numbers of various forms.

Of course, if you can choose C big enough so X mod C = X, then it is easy.

See http://en.m.wikipedia.org/wiki/Smooth_number for a discussion of smooth numbers.

Keith Randall
A: 

Im not sure if I understand your question correctly, but if you are given Z and C and you want to calculate X.

If X mod C = Z, then this means that for some natural number q it holds that qC+Z = X, since q is unknown, it is in general impossible to calculate X exactly, however, there is an infinite set of numbers satisfying this equation. This is also not strange. Assume you have some X' which could be the solution, then also X'' = X'+C is a solution equally valid.

Whether or not C and X are coprime (i.e. they (dont) have common prime factors) is not relevant, if I'm not mistaking. However, it makes your solution set a bit smaller, because if X and C have common prime factors say p1,p2,...pn, than each valid solution should also be divisible by p1*p2*...*pn.

Henri
A: 

There are infinite primes (and thus infinite products of N primes), but only C possible values of X mod C. Thus, with overwhelming probability, there will be infinite valid X which satisfy X mod C = Z.

So, if you are looking to determine which of those was your original X, then no, that can't be done.

BlueRaja - Danny Pflughoeft