for i = 1 to 11 print "F"; i; " = "; call farey(i, FALSE) next i print for i = 100 to 1000 step 100 print "F"; i; if i <> 1000 then print " "; else print ""; print " = "; call farey(i, FALSE) next i end subroutine farey(n, descending) a = 0 : b = 1 : c = 1 : d = n : k = 0 cont = 0 if descending = TRUE then a = 1 : c = n -1 end if cont += 1 if n < 12 then print a; "/"; b; " "; while ((c <= n) and not descending) or ((a > 0) and descending) aa = a : bb = b : cc = c : dd = d k = (n + b) \ d a = cc : b = dd : c = k * cc - aa : d = k * dd - bb cont += 1 if n < 12 then print a; "/"; b; " "; end while if n < 12 then print else print rjust(cont,7) end subroutine