0

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"?

N. F. Taussig
  • 76,571
kingzone
  • 125

0 Answers0