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.
( 45, 0, 12 ), ( 45, 15, 8 ), ( 45, 30, 4 ),
( 60, 0, 16 ), ( 60, 15, 12 ), ( 60, 30, 8 ), ( 60, 45, 4 ),
( 75, 0, 20 ), ( 75, 15, 16 ), ( 75, 30, 12 ), ( 75, 45, 8 ), ( 75, 60, 4 ),
( 90, 0, 24 ), ( 90, 15, 20 ), ( 90, 30, 16 ), ( 90, 45, 12 ), ( 90, 60, 8 ), ( 90, 75, 4 ),
( 105, 0, 28 ), ( 105, 15, 24 ), ( 105, 30, 20 ), ( 105, 45, 16 ), ( 105, 60, 12 ), ( 105, 75, 8 ), ( 105, 90, 4 ),
( 120, 0, 32 ), ( 120, 15, 28 ), ( 120, 30, 24 ), ( 120, 45, 20 ), ( 120, 60, 16 ), ( 120, 75, 12 ), ( 120, 90, 8 ), ( 120, 105, 4 ),
( 135, 0, 36 ), ( 135, 15, 32 ), ( 135, 30, 28 ), ( 135, 45, 24 ), ( 135, 60, 20 ), ( 135, 75, 16 ), ( 135, 90, 12 ), ( 135, 105, 8 ), ( 135, 120, 4 ),
( 150, 0, 40 ), ( 150, 15, 36 ), ( 150, 30, 32 ), ( 150, 45, 28 ), ( 150, 60, 24 ), ( 150, 75, 20 ), ( 150, 90, 16 ), ( 150, 105, 12 ), ( 150, 120, 8 ), ( 150, 135, 4 ),
( 165, 0, 44 ), ( 165, 15, 40 ), ( 165, 30, 36 ), ( 165, 45, 32 ), ( 165, 60, 28 ), ( 165, 75, 24 ), ( 165, 90, 20 ), ( 165, 105, 16 ), ( 165, 120, 12 ), ( 165, 135, 8 ), ( 165, 150, 4 ),
( 180, 0, 48 ), ( 180, 15, 44 ), ( 180, 30, 40 ), ( 180, 45, 36 ), ( 180, 60, 32 ), ( 180, 75, 28 ), ( 180, 90, 24 ), ( 180, 105, 20 ), ( 180, 120, 16 ), ( 180, 135, 12 ), ( 180, 150, 8 ), ( 180, 165, 4 ),
( 195, 0, 52 ), ( 195, 15, 48 ), ( 195, 30, 44 ), ( 195, 45, 40 ), ( 195, 60, 36 ), ( 195, 75, 32 ), ( 195, 90, 28 ), ( 195, 105, 24 ), ( 195, 120, 20 ), ( 195, 135, 16 ), ( 195, 150, 12 ), ( 195, 165, 8 ), ( 195, 180, 4 ),
( 210, 0, 56 ), ( 210, 15, 52 ), ( 210, 30, 48 ), ( 210, 45, 44 ), ( 210, 60, 40 ), ( 210, 75, 36 ), ( 210, 90, 32 ), ( 210, 105, 28 ), ( 210, 120, 24 ), ( 210, 135, 20 ), ( 210, 150, 16 ), ( 210, 165, 12 ), ( 210, 180, 8 ), ( 210, 195, 4 ),
...
}
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 "}"