Farey sequence: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|Perl 6}}: clean up the forest of parenthesis a bit)
m (tidy up task description)
Line 1: Line 1:
{{draft task}}
{{draft task}}
The [[wp:Farey sequence|Farey sequence]] (sometimes incorrectly called a Farey series) <math>\textbf{\textit{F}}_n</math> of order <math>n</math> is the sequence of completely reduced fractions between <math>0</math> and <math>1</math> which, when in lowest terms, have denominators less than or equal to <math>n</math>, arranged in order of increasing size.


Each Farey sequence starts with value <math>0</math>, denoted by the fraction <math> \frac{0}{1} </math> and ends with the value <math>1</math>, denoted by the fraction <math> \frac{1}{1}</math>.
;Farey sequence
The Farey sequences of orders <math>1</math> to <math>5</math> are:
(sometimes incorrectly called a Farey series.)
:<math>\textbf{\textit{F}}_1 = \frac{0}{1}, \frac{1}{1}</math>
:<br>
:<math>\textbf{\textit{F}}_2 = \frac{0}{1}, \frac{1}{2}, \frac{1}{1}</math>
:<br>
:<math>\textbf{\textit{F}}_3 = \frac{0}{1}, \frac{1}{3}, \frac{1}{2}, \frac{2}{3}, \frac{1}{1}</math>
:<br>
:<math>\textbf{\textit{F}}_4 = \frac{0}{1}, \frac{1}{4}, \frac{1}{3}, \frac{1}{2}, \frac{2}{3}, \frac{3}{4}, \frac{1}{1}</math>
:<br>
:<math>\textbf{\textit{F}}_5 = \frac{0}{1}, \frac{1}{5}, \frac{1}{4}, \frac{1}{3}, \frac{2}{5}, \frac{1}{2}, \frac{3}{5}, \frac{2}{3}, \frac{3}{4}, \frac{4}{5}, \frac{1}{1}</math>


;Task
;definition:
* Compute and show the Farey sequence for orders <math>1</math> through <math>11</math> (inclusive).

* Compute and display the ''number'' of fractions in the Farey sequence for order <math>100</math> through <math>1000</math> (inclusive) by hundreds.
The Farey sequence ''' ''F''<sub>n</sub> ''' of order '''n''' is the sequence of completely reduced fractions between '''0''' and '''1''' which,
;See also
when in lowest terms, have denominators less than or equal to '''n''', arranged in order of increasing size.
* Sequence [http://oeis.org/A006842 A006842 numerators of Farey series of order 1, 2, ···] on OEIS.

* Sequence [http://oeis.org/A006843 A006843 denominators of Farey series of order 1, 2, ···] on OEIS.
Each Farey sequence starts with value &nbsp; <big><big>'''0'''</big></big>, &nbsp; denoted by the fraction &nbsp; <small><small><math> \frac{0}{1} </math></small></small> &nbsp; and ends with the value &nbsp; <big><big>'''1'''</big></big>, &nbsp; denoted by the fraction &nbsp; <small><small><math> \frac{1}{1}</math></small></small>.
* Sequence [http://oeis.org/A005728 A005728 number of fractions in Farey series of order n.] on OEIS.

* Entry [http://mathworld.wolfram.com/FareySequence.html Farey sequence] on Mathworld.
The Farey sequences of orders &nbsp; 1 &nbsp; to &nbsp; 5 &nbsp; are: <br><br>
<!-- I had trouble concerning the comma placement in displaying the Farey sequence, it probably should have a «sup» , «/sup» to help align it with the dash in the fractions; plus, a <nowiki> &nbsp; </nowiki> causes some kind of parsing error (with a red error message). -- Gerard Schildberger -->
:<big><big>''' ''F''<sub>1</sub>''' = &nbsp; &nbsp; </big></big><small><small><math> \frac{0}{1} , \frac{1}{1} </math></small></small><br><br>
:<big><big>''' ''F''<sub>2</sub>''' = &nbsp; &nbsp; </big></big><small><small><math> \frac{0}{1} , \frac{1}{2} , \frac{1}{1} </math></small></small><br><br>
:<big><big>''' ''F''<sub>3</sub>''' = &nbsp; &nbsp; </big></big><small><small><math> \frac{0}{1} , \frac{1}{3} , \frac{1}{2} , \frac{2}{3} , \frac{1}{1} </math></small></small><br><br>
:<big><big>''' ''F''<sub>4</sub>''' = &nbsp; &nbsp; </big></big><small><small><math> \frac{0}{1} , \frac{1}{4} , \frac{1}{3} , \frac{1}{2} , \frac{2}{3} , \frac{3}{4} , \frac{1}{1} </math></small></small><br><br>
:<big><big>''' ''F''<sub>5</sub>''' = &nbsp; &nbsp; </big></big><small><small><math> \frac{0}{1} , \frac{1}{5} , \frac{1}{4} , \frac{1}{3} , \frac{2}{5} , \frac{1}{2} , \frac{3}{5} , \frac{2}{3} , \frac{3}{4} , \frac{4}{5} , \frac{1}{1} </math></small></small><br><br>

;task requirements:

* compute and show the Farey sequence for order &nbsp; '''1''' &nbsp; through &nbsp; '''11''' &nbsp; (inclusive).
* compute and display the number of fractions in the Farey sequence for order &nbsp; '''100''' &nbsp; through &nbsp; '''1,000''' &nbsp; (inclusive) &nbsp; by hundreds.

;see also:
* sequence [http://oeis.org/A006842 A006842 numerators of Farey series of order 1, 2, ···] on OEIS, The On-line Encyclopedia of Integer Sequences (R).
* sequence [http://oeis.org/A006843 A006843 denominators of Farey series of order 1, 2, ···] on OEIS, The On-line Encyclopedia of Integer Sequences (R).
* sequence [http://oeis.org/A005728 A005728 number of fractions in Farey series of order n.] on OEIS, The On-line Encyclopedia of Integer Sequences (R).
* entry [http://mathworld.wolfram.com/FareySequence.html Farey sequence] on Wolfram Mathworld (TM).
* Wiki [http://en.wikipedia.org/wiki/Farey_sequence Farey sequence] in Wikipedia.


=={{header|D}}==
=={{header|D}}==

Revision as of 08:45, 1 April 2014

Farey sequence is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The Farey sequence (sometimes incorrectly called a Farey series) of order is the sequence of completely reduced fractions between and which, when in lowest terms, have denominators less than or equal to , arranged in order of increasing size.

Each Farey sequence starts with value , denoted by the fraction and ends with the value , denoted by the fraction . The Farey sequences of orders to are:





Task
  • Compute and show the Farey sequence for orders through (inclusive).
  • Compute and display the number of fractions in the Farey sequence for order through (inclusive) by hundreds.
See also

D

This imports the module from the Arithmetic/Rational task.

Translation of: Python

<lang d>import std.stdio, std.algorithm, std.range, arithmetic_rational;

auto farey(in int n) /*pure nothrow*/ {

   auto res = [RationalT!int(0, 1)];
   foreach (immutable k; 1 .. n + 1)
       res ~= iota(1, k + 1).map!(m => RationalT!int(m, k)).array;
   return res.sort().uniq;

}

long fareyLen(in long n) pure nothrow {

   return (n * (n+3)) / 2 - iota(2, n+1).map!(k => fareyLen(n/k)).sum;

}

void main() {

   writefln("Farey sequence for order 1 through 11:\n%(%s\n%)",
            iota(1, 12).map!farey);
   writeln("\nNumber of fractions in the Farey sequence "
           "for order 100 through 1000 by hundreds:\n",
           iota(100, 1_001, 100).map!fareyLen);

}</lang>

Output:
Farey sequence for order 1 through 11:
[0, 1]
[0, 1/2, 1]
[0, 1/3, 1/2, 2/3, 1]
[0, 1/4, 1/3, 1/2, 2/3, 3/4, 1]
[0, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1]
[0, 1/6, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 1]
[0, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 2/5, 3/7, 1/2, 4/7, 3/5, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 1]
[0, 1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8, 1]
[0, 1/9, 1/8, 1/7, 1/6, 1/5, 2/9, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 4/9, 1/2, 5/9, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 7/9, 4/5, 5/6, 6/7, 7/8, 8/9, 1]
[0, 1/10, 1/9, 1/8, 1/7, 1/6, 1/5, 2/9, 1/4, 2/7, 3/10, 1/3, 3/8, 2/5, 3/7, 4/9, 1/2, 5/9, 4/7, 3/5, 5/8, 2/3, 7/10, 5/7, 3/4, 7/9, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 1]
[0, 1/11, 1/10, 1/9, 1/8, 1/7, 1/6, 2/11, 1/5, 2/9, 1/4, 3/11, 2/7, 3/10, 1/3, 4/11, 3/8, 2/5, 3/7, 4/9, 5/11, 1/2, 6/11, 5/9, 4/7, 3/5, 5/8, 7/11, 2/3, 7/10, 5/7, 8/11, 3/4, 7/9, 4/5, 9/11, 5/6, 6/7, 7/8, 8/9, 9/10, 10/11, 1]

Number of fractions in the Farey sequence for order 100 through 1000 by hundreds:
[3045, 12233, 27399, 48679, 76117, 109501, 149019, 194751, 246327, 304193]

Perl 6

<lang perl6>sub farey ($order) { (0/1, (1..$order).map: {(1..$^d).map: { $^n/$d } }).Set.list }

sub pp (Rat $r) { sprintf "%d/%d", $r.nude }

say "Farey sequence order "; say "$_: ", .&farey.sort>>.&pp for 1..11; say "Farey sequence order $_ has ", [.&farey].elems, ' elements.' for 100, 200 ... 1000;</lang>

Output:
Farey sequence order 
1: 0/1 1/1
2: 0/1 1/2 1/1
3: 0/1 1/3 1/2 2/3 1/1
4: 0/1 1/4 1/3 1/2 2/3 3/4 1/1
5: 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1
6: 0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1
7: 0/1 1/7 1/6 1/5 1/4 2/7 1/3 2/5 3/7 1/2 4/7 3/5 2/3 5/7 3/4 4/5 5/6 6/7 1/1
8: 0/1 1/8 1/7 1/6 1/5 1/4 2/7 1/3 3/8 2/5 3/7 1/2 4/7 3/5 5/8 2/3 5/7 3/4 4/5 5/6 6/7 7/8 1/1
9: 0/1 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 1/1
10: 0/1 1/10 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 3/10 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 7/10 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 9/10 1/1
11: 0/1 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 3/7 4/9 5/11 1/2 6/11 5/9 4/7 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 1/1
Farey sequence order 100 has 3045 elements.
Farey sequence order 200 has 12233 elements.
Farey sequence order 300 has 27399 elements.
Farey sequence order 400 has 48679 elements.
Farey sequence order 500 has 76117 elements.
Farey sequence order 600 has 109501 elements.
Farey sequence order 700 has 149019 elements.
Farey sequence order 800 has 194751 elements.
Farey sequence order 900 has 246327 elements.
Farey sequence order 1000 has 304193 elements.

Python

<lang python>from fractions import Fraction


class Fr(Fraction):

   def __repr__(self):
       return '(%s/%s)' % (self.numerator, self.denominator)


def farey(n, length=False):

   if not length:
       return [Fr(0, 1)] + sorted({Fr(m, k) for k in range(1, n+1) for m in range(1, k+1)})
   else:
       #return 1         +    len({Fr(m, k) for k in range(1, n+1) for m in range(1, k+1)})
       return  (n*(n+3))//2 - sum(farey(n//k, True) for k in range(2, n+1))
       

if __name__ == '__main__':

   print('Farey sequence for order 1 through 11 (inclusive):')
   for n in range(1, 12): 
       print(farey(n))
   print('Number of fractions in the Farey sequence for order 100 through 1,000 (inclusive) by hundreds:')
   print([farey(i, length=True) for i in range(100, 1001, 100)])</lang>
Output:
Farey sequence for order 1 through 11 (inclusive):
[(0/1), (1/1)]
[(0/1), (1/2), (1/1)]
[(0/1), (1/3), (1/2), (2/3), (1/1)]
[(0/1), (1/4), (1/3), (1/2), (2/3), (3/4), (1/1)]
[(0/1), (1/5), (1/4), (1/3), (2/5), (1/2), (3/5), (2/3), (3/4), (4/5), (1/1)]
[(0/1), (1/6), (1/5), (1/4), (1/3), (2/5), (1/2), (3/5), (2/3), (3/4), (4/5), (5/6), (1/1)]
[(0/1), (1/7), (1/6), (1/5), (1/4), (2/7), (1/3), (2/5), (3/7), (1/2), (4/7), (3/5), (2/3), (5/7), (3/4), (4/5), (5/6), (6/7), (1/1)]
[(0/1), (1/8), (1/7), (1/6), (1/5), (1/4), (2/7), (1/3), (3/8), (2/5), (3/7), (1/2), (4/7), (3/5), (5/8), (2/3), (5/7), (3/4), (4/5), (5/6), (6/7), (7/8), (1/1)]
[(0/1), (1/9), (1/8), (1/7), (1/6), (1/5), (2/9), (1/4), (2/7), (1/3), (3/8), (2/5), (3/7), (4/9), (1/2), (5/9), (4/7), (3/5), (5/8), (2/3), (5/7), (3/4), (7/9), (4/5), (5/6), (6/7), (7/8), (8/9), (1/1)]
[(0/1), (1/10), (1/9), (1/8), (1/7), (1/6), (1/5), (2/9), (1/4), (2/7), (3/10), (1/3), (3/8), (2/5), (3/7), (4/9), (1/2), (5/9), (4/7), (3/5), (5/8), (2/3), (7/10), (5/7), (3/4), (7/9), (4/5), (5/6), (6/7), (7/8), (8/9), (9/10), (1/1)]
[(0/1), (1/11), (1/10), (1/9), (1/8), (1/7), (1/6), (2/11), (1/5), (2/9), (1/4), (3/11), (2/7), (3/10), (1/3), (4/11), (3/8), (2/5), (3/7), (4/9), (5/11), (1/2), (6/11), (5/9), (4/7), (3/5), (5/8), (7/11), (2/3), (7/10), (5/7), (8/11), (3/4), (7/9), (4/5), (9/11), (5/6), (6/7), (7/8), (8/9), (9/10), (10/11), (1/1)]
Number of fractions in the Farey sequence for order 100 through 1,000 (inclusive) by hundreds:
[3045, 12233, 27399, 48679, 76117, 109501, 149019, 194751, 246327, 304193]

Racket

Once again, racket's math/number-theory package comes to the rescue! <lang racket>#lang racket (require math/number-theory) (define (display-farey-sequence order show-fractions?)

 (define f-s (farey-sequence order))
 (printf "-- Farey Sequence for order ~a has ~a fractions~%" order (length f-s))
 ;; racket will simplify 0/1 and 1/1 to 0 and 1 respectively, so deconstruct into numerator and
 ;; denomimator (and take the opportunity to insert commas
 (when show-fractions?
   (displayln
    (string-join
     (for/list ((f f-s))
       (format "~a/~a" (numerator f) (denominator f)))
     ", "))))
compute and show the Farey sequence for order
1 through 11 (inclusive).

(for ((order (in-range 1 (add1 11)))) (display-farey-sequence order #t))

compute and display the number of fractions in the Farey sequence for order
100 through 1,000 (inclusive) by hundreds.

(for ((order (in-range 100 (add1 1000) 100))) (display-farey-sequence order #f))</lang>

Output:
-- Farey Sequence for order 1 has 2 fractions
0/1, 1/1
-- Farey Sequence for order 2 has 3 fractions
0/1, 1/2, 1/1
-- Farey Sequence for order 3 has 5 fractions
0/1, 1/3, 1/2, 2/3, 1/1
-- Farey Sequence for order 4 has 7 fractions
0/1, 1/4, 1/3, 1/2, 2/3, 3/4, 1/1
-- Farey Sequence for order 5 has 11 fractions
0/1, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1/1
-- Farey Sequence for order 6 has 13 fractions
0/1, 1/6, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 1/1
-- Farey Sequence for order 7 has 19 fractions
0/1, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 2/5, 3/7, 1/2, 4/7, 3/5, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 1/1
-- Farey Sequence for order 8 has 23 fractions
0/1, 1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8, 1/1
-- Farey Sequence for order 9 has 29 fractions
0/1, 1/9, 1/8, 1/7, 1/6, 1/5, 2/9, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 4/9, 1/2, 5/9, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 7/9, 4/5, 5/6, 6/7, 7/8, 8/9, 1/1
-- Farey Sequence for order 10 has 33 fractions
0/1, 1/10, 1/9, 1/8, 1/7, 1/6, 1/5, 2/9, 1/4, 2/7, 3/10, 1/3, 3/8, 2/5, 3/7, 4/9, 1/2, 5/9, 4/7, 3/5, 5/8, 2/3, 7/10, 5/7, 3/4, 7/9, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 1/1
-- Farey Sequence for order 11 has 43 fractions
0/1, 1/11, 1/10, 1/9, 1/8, 1/7, 1/6, 2/11, 1/5, 2/9, 1/4, 3/11, 2/7, 3/10, 1/3, 4/11, 3/8, 2/5, 3/7, 4/9, 5/11, 1/2, 6/11, 5/9, 4/7, 3/5, 5/8, 7/11, 2/3, 7/10, 5/7, 8/11, 3/4, 7/9, 4/5, 9/11, 5/6, 6/7, 7/8, 8/9, 9/10, 10/11, 1/1
-- Farey Sequence for order 100 has 3045 fractions
-- Farey Sequence for order 200 has 12233 fractions
-- Farey Sequence for order 300 has 27399 fractions
-- Farey Sequence for order 400 has 48679 fractions
-- Farey Sequence for order 500 has 76117 fractions
-- Farey Sequence for order 600 has 109501 fractions
-- Farey Sequence for order 700 has 149019 fractions
-- Farey Sequence for order 800 has 194751 fractions
-- Farey Sequence for order 900 has 246327 fractions
-- Farey Sequence for order 1000 has 304193 fractions

REXX

<lang rexx>/*REXX program computes & shows a Farey sequence (or the # of fractions)*/ parse arg L H I . /*get optional values from C.L. */ if L== then L=5 /*L not specified? Use default.*/ oldL=L /*original L (negativity=noshow)*/ L=abs(L) /*but ··· use |L| for all else.*/ if H== then H=L /*H not specified? Use default.*/ if I== then I=1 /*I " " " " */

    do n=L  to  H  by I               /*process range (could be only 1)*/
    @=fareyF(n);    #=' 'words(@)" "  /*go ye forth & compute Farey #s.*/
    say center('Farey sequence for order '   n   " has"   #   'fractions.', 150, '═')
    if oldL<0  then iterate           /*don't show Farey fractions if -*/
    say @;          say               /*show Farey fractions+blank line*/
    end   /*n*/                       /* [↑] build/show Farey fractions*/

exit /*stick a fork in it, we're done.*/ /*──────────────────────────────────FAREYF subroutine───────────────────*/ fareyf: procedure; parse arg x; n.1=0; d.1=1; n.2=1; d.2=x /*kit parts.*/ $=n.1'/'d.1 n.2"/"d.2 /*a starter kit for the Farey seq*/

                                      /* [↓]  now, build on the starter*/
         do j=1;  y=j+1;  z=j+2       /*construct from thirds on "up". */
         n.z=((d.j+x)%d.y)*n.y-n.j    /*    "     fraction numerator.  */
         d.z=((d.j+x)%d.y)*d.y-d.j    /*    "         "    denominator.*/
         if n.z>x  then leave         /*Should construction be stopped?*/
         $=$ n.z'/'d.z                /*Heck no, add this to party mix.*/
         end   /*j*/                  /* [↑]  construct the Farey seq. */

return $ /*return with the fractions. */</lang> output when using the following for input:   1 11

═══════════════════════════════════════════════════Farey sequence for order  1  has  2  fractions.════════════════════════════════════════════════════
0/1 1/1

═══════════════════════════════════════════════════Farey sequence for order  2  has  3  fractions.════════════════════════════════════════════════════
0/1 1/2 1/1

═══════════════════════════════════════════════════Farey sequence for order  3  has  5  fractions.════════════════════════════════════════════════════
0/1 1/3 1/2 2/3 1/1

═══════════════════════════════════════════════════Farey sequence for order  4  has  7  fractions.════════════════════════════════════════════════════
0/1 1/4 1/3 1/2 2/3 3/4 1/1

═══════════════════════════════════════════════════Farey sequence for order  5  has  11  fractions.═══════════════════════════════════════════════════
0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1

═══════════════════════════════════════════════════Farey sequence for order  6  has  13  fractions.═══════════════════════════════════════════════════
0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1

═══════════════════════════════════════════════════Farey sequence for order  7  has  19  fractions.═══════════════════════════════════════════════════
0/1 1/7 1/6 1/5 1/4 2/7 1/3 2/5 3/7 1/2 4/7 3/5 2/3 5/7 3/4 4/5 5/6 6/7 1/1

═══════════════════════════════════════════════════Farey sequence for order  8  has  23  fractions.═══════════════════════════════════════════════════
0/1 1/8 1/7 1/6 1/5 1/4 2/7 1/3 3/8 2/5 3/7 1/2 4/7 3/5 5/8 2/3 5/7 3/4 4/5 5/6 6/7 7/8 1/1

═══════════════════════════════════════════════════Farey sequence for order  9  has  29  fractions.═══════════════════════════════════════════════════
0/1 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 1/1

══════════════════════════════════════════════════Farey sequence for order  10  has  33  fractions.═══════════════════════════════════════════════════
0/1 1/10 1/9 1/8 1/7 1/6 1/5 2/9 1/4 2/7 3/10 1/3 3/8 2/5 3/7 4/9 1/2 5/9 4/7 3/5 5/8 2/3 7/10 5/7 3/4 7/9 4/5 5/6 6/7 7/8 8/9 9/10 1/1

══════════════════════════════════════════════════Farey sequence for order  11  has  43  fractions.═══════════════════════════════════════════════════
0/1 1/11 1/10 1/9 1/8 1/7 1/6 2/11 1/5 2/9 1/4 3/11 2/7 3/10 1/3 4/11 3/8 2/5 3/7 4/9 5/11 1/2 6/11 5/9 4/7 3/5 5/8 7/11 2/3 7/10 5/7 8/11 3/4 7/9 4/5 9/11 5/6 6/7 7/8 8/9 9/10 10/11 1/1

output when using the following for input:   -100 1000 100

═════════════════════════════════════════════════Farey sequence for order  100  has  3045  fractions.═════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  200  has  12233  fractions.═════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  300  has  27399  fractions.═════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  400  has  48679  fractions.═════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  500  has  76117  fractions.═════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  600  has  109501  fractions.════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  700  has  149019  fractions.════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  800  has  194751  fractions.════════════════════════════════════════════════
════════════════════════════════════════════════Farey sequence for order  900  has  246327  fractions.════════════════════════════════════════════════
═══════════════════════════════════════════════Farey sequence for order 10000  has  304193  fractions.════════════════════════════════════════════════