[seqfan] Re: Farey series A006842/A006843

Peter Luschny peter.luschny at googlemail.com
Mon Apr 27 22:01:42 CEST 2009


PL> A006842 has offset 1, but A006843 has offset 0.

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

OG> Here is one possible Mathematica Code

Thank you Olivier! With regard to the offset issue
this just adds another variant ;-))

Flatten[Table[FareyNumerators[n], {n,0,3}]]
{0, 0, 0, 1, 1, 0, 1, 1, 2, 1}
Flatten[Table[FareyDenominators[n], {n,0,3}]]
{1, 1, 1, 2, 1, 1, 3, 2, 3, 1}

The Mathematica code of Robert G. Wilson as stated
on OEIS gives

Flatten[Table[Numerator[Farey[n]], {n,0,3}]]
{0, 0, 1, 0, 1, 1, 0, 1, 1, 2, 1}
Flatten[Table[Denominator[Farey[n]], {n,0,3}]]
{1, 1, 1, 1, 2, 1, 1, 3, 2, 3, 1}

Today I saw that R. J. Mathar changed offset
of A006843 (=order of first row) to 1.

Well, now the official offsets of A006842 and
A006843 are the same. However Richard forgot
to adapt Roberts programs which should read now

Flatten[Table[Numerator[Farey[n]], {n,1,3}]]
{0, 1, 0, 1, 1, 0, 1, 1, 2, 1}
Flatten[Table[Denominator[Farey[n]], {n,1,3}]]
{1, 1, 1, 2, 1, 1, 3, 2, 3, 1}

Much confusion! I hope the following Maple code
is in sync with the sequence and the offset.

-----------------------------------

Farey := proc(n, C) local f,k;
f := proc(n) local a, b, c, d, k, t;
a := `if`(n=1,1,0); b:=1; c:=1; d:=n; t:=[a, b];
while (c < n) do k := iquo(n + b, d);
a, b, c, d := c, d, k*c - a, k*d - b;
t := t,[a,b] od; t end: [seq(f(k),k=0..n)];
`if`(C=1 or C=2,map(x->op(C,x),%),%) end:

# A006842 FareyNumer := proc(n) Farey(n,1) end:
# A006843 FareyDenom := proc(n) Farey(n,2) end:
# OERS    FareyRatio := proc(n) Farey(n,0) end:

FareyNumer(3); [0, 1, 0, 1, 1, 0, 1, 1, 2, 1]
FareyDenom(3); [1, 1, 1, 2, 1, 1, 3, 2, 3, 1]
FareyRatio(3); [0,1],[1,1],[0,1],[1,2],[1,1],
               [0,1],[1,3],[1,2],[2,3],[1,1]

-----------------------------------

Cheers Peter




More information about the SeqFan mailing list