Ops: corrected prime algorithm
John Thingstad
john.thingstad at chello.no
Sun Oct 21 17:59:58 EDT 2001
More information about the Python-list mailing list
Sun Oct 21 17:59:58 EDT 2001
- Previous message (by thread): editing .asp in PythonWin
- Next message (by thread): Ops: corrected prime algorithm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just checked my own algorithm and found several mistakes. Here is the correct algorithm: def prime(n): set = [2] + range(3,n, 2) for n in range(3, int(math.sqrt(n))+1, 2): set = [x for x in set if x == n or x % n != 0] return set
- Previous message (by thread): editing .asp in PythonWin
- Next message (by thread): Ops: corrected prime algorithm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list