The following algorithm can be applied to a list of fractions and an integer input. You go down the list and multiply the input by the first fraction that will result in an integer. Taking this product as the new input, you repeat, using the same list of fractions. The algorithm ends when none of the fractions will result in an integer.
For example, if the list of fractions is {5/6, 5/2, 5/3}, then inputting an integer 2a * 3b will result in 5max(a,b). A more complicated example: inputting 2a * 3b into {7/11, 11/(3*7), 1/7, (5*7)/2, 3/5} will result in 3a (if a>0).
Find a list of fractions such that inputting an integer 2a * 3b will result in 5ab.
How about a list that, when the input is 2a * 3b, results in 5a^b (with b>0)?
Here is the a*b list:
{11/13, (7*13)/(11*2), 1/11, (5*2)/7, (7*11)/(2*3), 1/2, 1/3}
and the a^b list :
{(11*11)/(13*13), (7*13*13)/(11*11*2), 13/(11*11), 11/13, (17*2*13)/(11*7), (7*13*13)/(2*5*11), 1/11, 5/17, (7*11*11)/(2*5*3), (7*11*11)/(2*3), 17/(2*5), 5/2, 1/3}
Note that this solution actually handles b=0 (it only took one extra fraction) treating 0^0 as 0
|
Posted by Joel
on 2006-11-21 22:55:04 |