On 2015-11-19 10:30, Eric Angelini wrote:
Hello Math-Funsters,
I was looking for a way to represent any fraction with one single integer. Do you know if there is a common way to do that or a paper about it?
Any method of showing that the rationals are countable implicitly has such a representation. There's a paper by ?? & Wilf on "counting the rationals", which, if I recall correctly, has an example of an explicit formula.
I came up with this (heavy?) idea: concatenate N and D and encode the place of the slash "/".
So, the fraction we want to represent is N/D. We build the integer NDBA with four concatenated strings of digits. Starting from the right:
A is a single digit B is a string that has length A (if A=0 then A=10) D is the denominator of the fraction N/D N is the numerator of the fraction N/D
To reconstruct the fraction N/D from NDBA we:
- read A - compute the length of B - read B - insert the symbol "/" after B digits, starting the count from the leftmost digit of NDBA - erase A and B
Examples:
The fraction 1/2 --> 1211 [or 12.1.1 --> 1/2] The fraction 113/355 --> 11335531 [113/355.3.1] The fraction 2015/1234567890 --> 2015123456789041 [2015/1234567890.4.1] The fraction 1234567890/888 --> 1234567890888102 [1234567890888.10.2] etc.
This system works for N having less than 10 billion digits, of course -- which seems ok in our everyday life (we would have an integer like ND.9999999999.0 with ten 9's)
Best, É.
P.-S. Many integers will not represent any fraction -- but this is another story (10211 would produce the fraction 1/02, for instance).
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun