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.
( 147, 0, 6 ), ( 147, 49, 4 ), ( 147, 98, 2 ),
( 196, 0, 8 ), ( 196, 49, 6 ), ( 196, 98, 4 ), ( 196, 147, 2 ),
( 245, 0, 10 ), ( 245, 49, 8 ), ( 245, 98, 6 ), ( 245, 147, 4 ), ( 245, 196, 2 ),
( 294, 0, 12 ), ( 294, 49, 10 ), ( 294, 98, 8 ), ( 294, 147, 6 ), ( 294, 196, 4 ), ( 294, 245, 2 ),
( 343, 0, 14 ), ( 343, 49, 12 ), ( 343, 98, 10 ), ( 343, 147, 8 ), ( 343, 196, 6 ), ( 343, 245, 4 ), ( 343, 294, 2 ),
( 392, 0, 16 ), ( 392, 49, 14 ), ( 392, 98, 12 ), ( 392, 147, 10 ), ( 392, 196, 8 ), ( 392, 245, 6 ), ( 392, 294, 4 ), ( 392, 343, 2 ),
( 441, 0, 18 ), ( 441, 49, 16 ), ( 441, 98, 14 ), ( 441, 147, 12 ), ( 441, 196, 10 ), ( 441, 245, 8 ), ( 441, 294, 6 ), ( 441, 343, 4 ), ( 441, 392, 2 ),
( 490, 0, 20 ), ( 490, 49, 18 ), ( 490, 98, 16 ), ( 490, 147, 14 ), ( 490, 196, 12 ), ( 490, 245, 10 ), ( 490, 294, 8 ), ( 490, 343, 6 ), ( 490, 392, 4 ), ( 490, 441, 2 ),
( 539, 0, 22 ), ( 539, 49, 20 ), ( 539, 98, 18 ), ( 539, 147, 16 ), ( 539, 196, 14 ), ( 539, 245, 12 ), ( 539, 294, 10 ), ( 539, 343, 8 ), ( 539, 392, 6 ), ( 539, 441, 4 ), ( 539, 490, 2 ),
( 588, 0, 24 ), ( 588, 49, 22 ), ( 588, 98, 20 ), ( 588, 147, 18 ), ( 588, 196, 16 ), ( 588, 245, 14 ), ( 588, 294, 12 ), ( 588, 343, 10 ), ( 588, 392, 8 ), ( 588, 441, 6 ), ( 588, 490, 4 ), ( 588, 539, 2 ),
( 637, 0, 26 ), ( 637, 49, 24 ), ( 637, 98, 22 ), ( 637, 147, 20 ), ( 637, 196, 18 ), ( 637, 245, 16 ), ( 637, 294, 14 ), ( 637, 343, 12 ), ( 637, 392, 10 ), ( 637, 441, 8 ), ( 637, 490, 6 ), ( 637, 539, 4 ), ( 637, 588, 2 ),
( 686, 0, 28 ), ( 686, 49, 26 ), ( 686, 98, 24 ), ( 686, 147, 22 ), ( 686, 196, 20 ), ( 686, 245, 18 ), ( 686, 294, 16 ), ( 686, 343, 14 ), ( 686, 392, 12 ), ( 686, 441, 10 ), ( 686, 490, 8 ), ( 686, 539, 6 ), ( 686, 588, 4 ), ( 686, 637, 2 ),
...
}
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 "}"