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.
( 15, 0, 6 ), ( 15, 5, 4 ), ( 15, 10, 2 ),
( 20, 0, 8 ), ( 20, 5, 6 ), ( 20, 10, 4 ), ( 20, 15, 2 ),
( 25, 0, 10 ), ( 25, 5, 8 ), ( 25, 10, 6 ), ( 25, 15, 4 ), ( 25, 20, 2 ),
( 30, 0, 12 ), ( 30, 5, 10 ), ( 30, 10, 8 ), ( 30, 15, 6 ), ( 30, 20, 4 ), ( 30, 25, 2 ),
( 35, 0, 14 ), ( 35, 5, 12 ), ( 35, 10, 10 ), ( 35, 15, 8 ), ( 35, 20, 6 ), ( 35, 25, 4 ), ( 35, 30, 2 ),
( 40, 0, 16 ), ( 40, 5, 14 ), ( 40, 10, 12 ), ( 40, 15, 10 ), ( 40, 20, 8 ), ( 40, 25, 6 ), ( 40, 30, 4 ), ( 40, 35, 2 ),
( 45, 0, 18 ), ( 45, 5, 16 ), ( 45, 10, 14 ), ( 45, 15, 12 ), ( 45, 20, 10 ), ( 45, 25, 8 ), ( 45, 30, 6 ), ( 45, 35, 4 ), ( 45, 40, 2 ),
( 50, 0, 20 ), ( 50, 5, 18 ), ( 50, 10, 16 ), ( 50, 15, 14 ), ( 50, 20, 12 ), ( 50, 25, 10 ), ( 50, 30, 8 ), ( 50, 35, 6 ), ( 50, 40, 4 ), ( 50, 45, 2 ),
( 55, 0, 22 ), ( 55, 5, 20 ), ( 55, 10, 18 ), ( 55, 15, 16 ), ( 55, 20, 14 ), ( 55, 25, 12 ), ( 55, 30, 10 ), ( 55, 35, 8 ), ( 55, 40, 6 ), ( 55, 45, 4 ), ( 55, 50, 2 ),
( 60, 0, 24 ), ( 60, 5, 22 ), ( 60, 10, 20 ), ( 60, 15, 18 ), ( 60, 20, 16 ), ( 60, 25, 14 ), ( 60, 30, 12 ), ( 60, 35, 10 ), ( 60, 40, 8 ), ( 60, 45, 6 ), ( 60, 50, 4 ), ( 60, 55, 2 ),
( 65, 0, 26 ), ( 65, 5, 24 ), ( 65, 10, 22 ), ( 65, 15, 20 ), ( 65, 20, 18 ), ( 65, 25, 16 ), ( 65, 30, 14 ), ( 65, 35, 12 ), ( 65, 40, 10 ), ( 65, 45, 8 ), ( 65, 50, 6 ), ( 65, 55, 4 ), ( 65, 60, 2 ),
( 70, 0, 28 ), ( 70, 5, 26 ), ( 70, 10, 24 ), ( 70, 15, 22 ), ( 70, 20, 20 ), ( 70, 25, 18 ), ( 70, 30, 16 ), ( 70, 35, 14 ), ( 70, 40, 12 ), ( 70, 45, 10 ), ( 70, 50, 8 ), ( 70, 55, 6 ), ( 70, 60, 4 ), ( 70, 65, 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 "}"