[seqfan] Re: Farey series A006842/A006843

Olivier Gerard olivier.gerard at gmail.com
Sun Apr 26 10:41:34 CEST 2009


On Sun, Apr 26, 2009 at 01:02, Peter Luschny
<peter.luschny at googlemail.com> wrote:
> The following nice non-recursive way
> to compute the Farey Tree has been
> discussed by Norman Routledge,
> "Computing Farey Series," The Mathematical
> Gazette, Vol. 29 (No. 523), 55–62 (March 2008).

It is not recursive on the previous set but it is recursive internally.

It maintains two steps of two associated sequences (4 values) and to
know when to stop it is computing implicitely  sum( eulerphi(i),  i=1..n )

>
> Perhaps this Maple code should be added to
> A006842/A006843 respectively?
>
> --

Here is one possible Mathematica Code

FareySequence[n_] :=
 Map[First,
  NestWhileList[{#1[[2]], #1[[2]]*
       Quotient[n + #1[[1, 2]], #[[2, 2]]] - #1[[1]]} &, {{0, 1}, {1, n}},
 #1[[2, 1]] < n & ]]

FareyNumerators[n_] := Map[First, FareySequence[n]]

FareyDenominators[n_] := Map[Last, FareySequence[n]]

> --
>
Olivier




More information about the SeqFan mailing list