This might not be the place to post this, but Im trying to write this in C++ and havent a clue how to go about it.
I am trying to generate a group of numbers in form of "(a/b) * (c/d)".
I supply a decimal for example, .12345 and I need to generate these groups of numbers that are close to this value within a certain amount, for example .00002.
What I have now is doing this through iteration with 4 for loops. Each letter can be between 20 and 105. This takes for ever when I have to keep checking the result against what I supplied and see if its within the error I need.
I think this is more of an actual math problem, but I was hoping maybe someone here might know how to go about this.
I am trying a new way using continued fraction, but once I get a fraction that is within my error, I am unsure how to break it up into the sizes I need
>=20 && <=105.
For example, using iteration, a ratio of .12345 with an error of .00002 one of the results is A=20, B=60, C=20, D=54.
When I use continued fraction, I get a fraction of 10/81.
So can someone help me turn a fraction of 10/81 into a group of numbers of A/B * C/D?
Get the factors of the numerator and denominator.
If each has more than two factors... consolidate into two numbers for each.
print the two fractions separated by (*)
e.g 10/81 = 5*2 / 3*3*3*3 = 5*2 /3*27 or 5*2 / 9*9.
so.. 10/81 = 5/3 * 2/27 or 5/9 * 2/9
The problem I have is visualizing how this is accomplished through programming.
There is another piece to this. Each Number has to be between 20 and 105. So even after I break it down into 5*2 / 3*3*3*3, I need to have some way to manipulate this into as many possibilities where they fall between 20 and 105.
Actually, I think I am going to stick with my iteration method for now. I need to really brush up on my fraction skills before I believe I am able to tackle this by program.