Post Reply 
(50g) Fun with Farey sequences
06-16-2015, 07:09 PM (This post was last modified: 06-17-2015 05:19 AM by Didier Lachieze.)
Post: #4
RE: (50g) Fun with Farey sequences
Thanks for the links. Great video !

I've adapted the Python program for the Prime:

Code:
#pragma mode( separator(.,;) integer(h32) )
EXPORT farey(n)
BEGIN
     LOCAL a:=0,b:=1,c:=1,d:=n,k,l;
     l:={ a/b };
     WHILE c < n DO
         k:=IP((n+b)/d);
         c:=−a+k*(a:=c); d:=-b+k*(b:=d);
         l:=CONCAT(l,a/b);
     END;  
     exact(l);
END;

The result is a list of reals, you need to press the "a b/c" key to display it as fractions. I don't know how to do it programmatically.
EDIT: edited to add exact() to the result as suggested by Joe below.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Fun with Farey sequences - Tugdual - 06-15-2015, 08:37 PM
RE: (50g) Fun with Farey sequences - Didier Lachieze - 06-16-2015 07:09 PM



User(s) browsing this thread: 1 Guest(s)