One way to define a rational number (a-b)/c is to define it as the (infinite) set of all 3-tuples of natural numbers (a1, b1, c1) for which (a-b)/c = (a1-b1)/c1 (b is needed for negative numbers).
Klick on a 3-tuple to see how it may be defined as a set.
( 99, 0, 24 ), ( 99, 33, 16 ), ( 99, 66, 8 ),
( 132, 0, 32 ), ( 132, 33, 24 ), ( 132, 66, 16 ), ( 132, 99, 8 ),
( 165, 0, 40 ), ( 165, 33, 32 ), ( 165, 66, 24 ), ( 165, 99, 16 ), ( 165, 132, 8 ),
( 198, 0, 48 ), ( 198, 33, 40 ), ( 198, 66, 32 ), ( 198, 99, 24 ), ( 198, 132, 16 ), ( 198, 165, 8 ),
( 231, 0, 56 ), ( 231, 33, 48 ), ( 231, 66, 40 ), ( 231, 99, 32 ), ( 231, 132, 24 ), ( 231, 165, 16 ), ( 231, 198, 8 ),
( 264, 0, 64 ), ( 264, 33, 56 ), ( 264, 66, 48 ), ( 264, 99, 40 ), ( 264, 132, 32 ), ( 264, 165, 24 ), ( 264, 198, 16 ), ( 264, 231, 8 ),
( 297, 0, 72 ), ( 297, 33, 64 ), ( 297, 66, 56 ), ( 297, 99, 48 ), ( 297, 132, 40 ), ( 297, 165, 32 ), ( 297, 198, 24 ), ( 297, 231, 16 ), ( 297, 264, 8 ),
( 330, 0, 80 ), ( 330, 33, 72 ), ( 330, 66, 64 ), ( 330, 99, 56 ), ( 330, 132, 48 ), ( 330, 165, 40 ), ( 330, 198, 32 ), ( 330, 231, 24 ), ( 330, 264, 16 ), ( 330, 297, 8 ),
( 363, 0, 88 ), ( 363, 33, 80 ), ( 363, 66, 72 ), ( 363, 99, 64 ), ( 363, 132, 56 ), ( 363, 165, 48 ), ( 363, 198, 40 ), ( 363, 231, 32 ), ( 363, 264, 24 ), ( 363, 297, 16 ), ( 363, 330, 8 ),
( 396, 0, 96 ), ( 396, 33, 88 ), ( 396, 66, 80 ), ( 396, 99, 72 ), ( 396, 132, 64 ), ( 396, 165, 56 ), ( 396, 198, 48 ), ( 396, 231, 40 ), ( 396, 264, 32 ), ( 396, 297, 24 ), ( 396, 330, 16 ), ( 396, 363, 8 ),
( 429, 0, 104 ), ( 429, 33, 96 ), ( 429, 66, 88 ), ( 429, 99, 80 ), ( 429, 132, 72 ), ( 429, 165, 64 ), ( 429, 198, 56 ), ( 429, 231, 48 ), ( 429, 264, 40 ), ( 429, 297, 32 ), ( 429, 330, 24 ), ( 429, 363, 16 ), ( 429, 396, 8 ),
( 462, 0, 112 ), ( 462, 33, 104 ), ( 462, 66, 96 ), ( 462, 99, 88 ), ( 462, 132, 80 ), ( 462, 165, 72 ), ( 462, 198, 64 ), ( 462, 231, 56 ), ( 462, 264, 48 ), ( 462, 297, 40 ), ( 462, 330, 32 ), ( 462, 363, 24 ), ( 462, 396, 16 ), ( 462, 429, 8 ),
...
}
The equation (a-b)/c = (a1-b1)/c1 is equivalent to a·c1 + b1·c = a1·c + b·c1 - so only addition and multiplication of natural numbers are needed to define the rational numbers.
For rational numbers Q, Q1 as defined above, Q < Q1 is defined as a·c1 + b1·c < a1·c + b·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.
Q + Q1 is defined as (a2-b2)/c2, where a2 = a·c1 + a1·c, b2 = b·c1 + b1·c, c2 = c·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.
Be aware that (a2-b2)/c2 is simply a notation for the set determined by a2, b2 and c2 here - not an expression using subtraction and division.
The definition for Q + Q1 above simply is a transformation of the expression (a-b)/c + (a1-b1)/c1.
Assuming that a,c is minimal for a positive rational number a/c or (a-0)/c, we can enumerate all members of the set by doing this:
Let n be 1 Repeat: For all n1 from 0 to n-1: Let a1 be n·a Let b1 be n1·a Let c1 be (n-n1)·c Enumerate (a1,b1,c1) Increase n by 1
The enumeration as Python function with a limiting parameter k which will cause the function to enumerate (k·(k+1))/2 elements of a/c:
def print_rational_number(a,c,k): print str(a)+'/'+str(c)+' = ('+str(a)+'-0)/'+str(c)+' = {' for n in range(1,k+1): for n1 in range(n): a1=n*a b1=n1*a c1=(n-n1)*c print '( '+str(a1)+', '+str(b1)+', '+str(c1)+' ),' print print "..." print "}"