division by 7 efficiently ???

Paul Rubin http
Thu Feb 1 03:51:40 CET 2007


krypto.wizard at gmail.com writes:
> How to divide a number by 7 efficiently without using - or / operator.
> We can use the bit operators. I was thinking about bit shift operator
> but I don't know the correct answer.

Erm, sounds like a homework problem... suggestion: think of how many
input bits you have, then check the accuracy of the obvious
approximations until you reach one that's precise enough.


More information about the Python-list mailing list