Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread Scott David Daniels
michel paul wrote: ... An interesting fact is that, except for 2 and 3, all primes are adjacent to a multiple of 6 Having once been interested in prime pairs, I remember having written a lot of code based on this back in the day. Here is my version of your generator: def primes():

Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread Andre Roberge
On Sun, Jan 18, 2009 at 7:31 PM, Gregor Lingl gregor.li...@aon.at wrote: [SNIP] == Summing up: Kirby 1.71 s 42.72 s Michel Paul1.58 s 32.25 s Michel Paul

Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread michel paul
On Sun, Jan 18, 2009 at 3:31 PM, Gregor Lingl gregor.li...@aon.at wrote: Michel Paul's code: def primes(): sofar = [-1, 2,3] # a running start, -1 proposed by J.H. Conway yield sofar[0] # get these out of the way yield sofar[1] # the only even prime yield sofar[2] # and then 3

Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread Gregor Lingl
michel paul schrieb: On Sun, Jan 18, 2009 at 3:31 PM, Gregor Lingl gregor.li...@aon.at mailto:gregor.li...@aon.at wrote: Michel Paul's code: def primes(): sofar = [-1, 2,3] # a running start, -1 proposed by J.H. Conway yield sofar[0] # get these out of the way

Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread Gregor Lingl
This is a corrected version of my previous posting. (1) According to the complaint of Michel I have inserted *his* code instead of Kirby's, which ocurred there (for a second time). (2) According to a suggestion of Andre I've added (towards the end of the posting) the code form the cookbook,

Re: [Edu-sig] Pythonic Math must include...

2009-01-18 Thread michel paul
On Sun, Jan 18, 2009 at 6:11 PM, Gregor Lingl gregor.li...@aon.at wrote: This exposes in my opinion an unsurmountable dilemma, namely that usually you cannot meet even those few criteria mentioned in the beginning in a single solution. I think it's OK that there's not a 'single' solution.