This is related to the so-called "Zaremba conjecture"; you can find articles about it with that keyword. It is known you can do it when B is a (sufficiently large) power of 2, 3, 5, and 6. The results are due to Niederreiter and others. Jeffrey Shallit On 9/11/13 9:14 PM, Warren D Smith wrote:
Consider a rational number (in reduced form) X=A/B.
Suppose I tell you B, and I ask you to "find A such that X has only 1s and 2s in its partial fraction expansion." (Even better, "...and with the fewest 2s.")
For example if B=2^32. You could by brute force just try all 2^32 possible A (actually only 2^31 if we insist A=odd) computing the continued fraction of each A/B,
Is there a faster method? How fast can you get? For which (if any) B's is the problem unsolvable?