Question: Sequence Procedure

I've written a procedure to generate a Farey sequence FN of order N where b=1,2,...,N & a=0,1,...b; as follows:

restart:
> farey:= proc(N::posint)
> local a,b,L:
> for b to N do:
>   for a to b do:
>   if a<=b then L:=sort([op({seq(seq(a/b,a=0..b),b=1..N)})]):
>   end if:
>  end do:
> end do:
> print(F[N]=L);
> end proc:

>farey(8);

  F[8] = [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]
 

Firstly, is this the best way to do it, i.e. is this the most efficient coding? Secondly, i now want to define a function L(N) whose value is the number of elements in FN. How do i plot the function y=3*N^2/L(N) on the same graph as the line y=PI^2 for N=1,2...100?

This is what i've done so far but am getting error messages:

> L:= N-> nops(farey(N)):
> plot({3*N^2/L,Pi^2},1..50);

Thanks.
 

Please Wait...