From: John Carter Date: 2007-03-20T08:07:26+09:00 Subject: Re: Golfing the Farey Sequence On Tue, 20 Mar 2007, Phrogz wrote: > You've left off the final "1/1" for the sequence > this way. Drat! You're right. I didn't notice N went into the front of the sequence. Ah well, I'm obliged to hunt an expensive shot then. Ooh. Wait, there is a very very cheap shot available... a,b,c,d=0,1,1,7 puts "#{a}/#{b}" while c<7 k = (N+b)/d e = k*c-a f=k*d-b a,b,c,d=c,d,e,f puts "#{a}/#{b}" end Now that's really low! Another less silly is... a,b,c,d=0,1,1,7 puts "#{a}/#{b}" while c<7 k = (N+b)/d e = k*c-a a,b,c,d=c,d,e,k*d-b puts "#{a}/#{b}" end But not much better. I suspect the next level up will be to trade storage space for lines of code. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand