I heard this interesting (at least interesting for me) algorithm from a junior high school student. This algorithm could generate all positive rational numbers. For $a_{i,j}=\frac{p}{q}$, we define $a_{i+1,2j-1}=\frac{p}{p+q}\ a_{i+1,2j}=\frac{p+q}{q}$ and if we let $a_{1,1}=\frac{1}{1}$ we can easily prove that $\forall i,j$ if $a_{i,j}=\frac{p}{q}$ then p and are obviously relatively prime. And for arbitrary rational numbers $\frac{p}{q}$ if $\exists i,j$ such that $a_{i,j}$ we can get $a_{i-1,\lfloor \frac{j}{2} \rfloor}$. By Euclidean Algorithm we will get $\frac{1}{n}=a_{n,1}$ or $\frac{n}{1}=a_{n,2^n}$ at the end. Which means that there exist and only exist one pair (i,j) such that $a_{i,j}=\frac{p}{q}$. In other words we could generate all rational numbers by this way. And if we let $a_{i,j}=b_{2^i+j-1}$ then we get a series of all positive rational numbers. This is not a difficult exercise but looks interested. Is there any background of this algorithm? Or this is just a "coincidence"?
Asked
Active
Viewed 58 times
0
-
1I know this technique as tree of fractions. Look here: https://www2.math.upenn.edu/~wilf/website/recounting.pdf – garondal Dec 30 '20 at 10:33
-
@garondal Thank you for your comment. It's really helpful. – kingzone Dec 30 '20 at 10:40
-
2It's called the Calkin-Wilf tree by some computer scientists. It appeared in various guises long ago in number theoretical contexts (e.g. see the keywords I give here, search for "diatomic" to locate the keywords). – Bill Dubuque Dec 30 '20 at 11:49
-
@BillDubuque Thank you for your comment. – kingzone Dec 30 '20 at 17:01