Solve equation on the PC

A friend of mine asked me to help him and make a small application to solve a problem. This problem can be reduced to this equation system:

aX = Yb; Y > c; Y < d; X is a whole number (X has nothing after . ); Y*10000 is a whole number (Y has no more then 4 digits after . );

eg. for a=185.5 b=1000000 c=4.3 d=4.4 a solution is X=23200 Y=4.3036

I have solved this doing this

for(i=c;i<d;i+=0.0001)
{
if(b/i is a whole number)
{
i have a solution
}
}


Is there a way to solve this more efficient? (from mathematical point of view can this be solved arithmetically?)

-
I'd look at the whole numbers $\frac{bc}{a} \le n \le \frac{bd}{a}$ and check whether for any such $n$ the fraction $\frac{10000an}{b}$ is a whole number. That should be faster. Are you interested in all solutions or do you only need one? – m_l Apr 18 '12 at 7:47
Your proposed solution certainly won't work as you wrote it. Repeatedly incrementing $i$ by $0.0001$ is a bad idea, since $0.0001$ cannot be represented exactly as a binary floating point number, so most over the time even $10000*i$ won't be a whole number. When you need to control the exact number of iterations, you should always use integer counters in loops, and if necessary calculate floating point numbers from these counters. Also do you mean "$i$ is a solution" or "I have a solution"? – Marc van Leeuwen Apr 18 '12 at 9:33