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.
( 105, 0, 27 ), ( 105, 35, 18 ), ( 105, 70, 9 ),
( 140, 0, 36 ), ( 140, 35, 27 ), ( 140, 70, 18 ), ( 140, 105, 9 ),
( 175, 0, 45 ), ( 175, 35, 36 ), ( 175, 70, 27 ), ( 175, 105, 18 ), ( 175, 140, 9 ),
( 210, 0, 54 ), ( 210, 35, 45 ), ( 210, 70, 36 ), ( 210, 105, 27 ), ( 210, 140, 18 ), ( 210, 175, 9 ),
( 245, 0, 63 ), ( 245, 35, 54 ), ( 245, 70, 45 ), ( 245, 105, 36 ), ( 245, 140, 27 ), ( 245, 175, 18 ), ( 245, 210, 9 ),
( 280, 0, 72 ), ( 280, 35, 63 ), ( 280, 70, 54 ), ( 280, 105, 45 ), ( 280, 140, 36 ), ( 280, 175, 27 ), ( 280, 210, 18 ), ( 280, 245, 9 ),
( 315, 0, 81 ), ( 315, 35, 72 ), ( 315, 70, 63 ), ( 315, 105, 54 ), ( 315, 140, 45 ), ( 315, 175, 36 ), ( 315, 210, 27 ), ( 315, 245, 18 ), ( 315, 280, 9 ),
( 350, 0, 90 ), ( 350, 35, 81 ), ( 350, 70, 72 ), ( 350, 105, 63 ), ( 350, 140, 54 ), ( 350, 175, 45 ), ( 350, 210, 36 ), ( 350, 245, 27 ), ( 350, 280, 18 ), ( 350, 315, 9 ),
( 385, 0, 99 ), ( 385, 35, 90 ), ( 385, 70, 81 ), ( 385, 105, 72 ), ( 385, 140, 63 ), ( 385, 175, 54 ), ( 385, 210, 45 ), ( 385, 245, 36 ), ( 385, 280, 27 ), ( 385, 315, 18 ), ( 385, 350, 9 ),
( 420, 0, 108 ), ( 420, 35, 99 ), ( 420, 70, 90 ), ( 420, 105, 81 ), ( 420, 140, 72 ), ( 420, 175, 63 ), ( 420, 210, 54 ), ( 420, 245, 45 ), ( 420, 280, 36 ), ( 420, 315, 27 ), ( 420, 350, 18 ), ( 420, 385, 9 ),
( 455, 0, 117 ), ( 455, 35, 108 ), ( 455, 70, 99 ), ( 455, 105, 90 ), ( 455, 140, 81 ), ( 455, 175, 72 ), ( 455, 210, 63 ), ( 455, 245, 54 ), ( 455, 280, 45 ), ( 455, 315, 36 ), ( 455, 350, 27 ), ( 455, 385, 18 ), ( 455, 420, 9 ),
( 490, 0, 126 ), ( 490, 35, 117 ), ( 490, 70, 108 ), ( 490, 105, 99 ), ( 490, 140, 90 ), ( 490, 175, 81 ), ( 490, 210, 72 ), ( 490, 245, 63 ), ( 490, 280, 54 ), ( 490, 315, 45 ), ( 490, 350, 36 ), ( 490, 385, 27 ), ( 490, 420, 18 ), ( 490, 455, 9 ),
...
}
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 "}"