division by 7 efficiently ???
Neil Cerutti
horpner at yahoo.com
Fri Feb 2 09:01:21 EST 2007
More information about the Python-list mailing list
Fri Feb 2 09:01:21 EST 2007
- Previous message (by thread): division by 7 efficiently ???
- Next message (by thread): division by 7 efficiently ???
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2007-02-01, Michael Yanowitz <m.yanowitz at kearfott.com> wrote: > I think it is off by 1 in small numbers, off by a little more with large > numbers: >>>> def div7 (N): > ... return (N>>3) + ((N-7*(N>>3))>>3) > ... >>>> div7 (70) > 9 >>>> div7 (77) > 10 >>>> div7 (700) > 98 >>>> div7 (7) > 0 >>>> div7 (10) > 1 >>>> div7 (14) > 1 >>>> div7 (21) > 2 >>>> div7 (700) > 98 >>>> div7 (7000) > 984 > Heh, heh. That's reminding of the "fabulous" O(n) Dropsort algorithm I saw linked from Effbot's blog. -- Neil Cerutti I'm tired of hearing about money, money, money, money, money. I just want to play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal
- Previous message (by thread): division by 7 efficiently ???
- Next message (by thread): division by 7 efficiently ???
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list