division by 7 efficiently ???
John Machin
sjmachin at lexicon.net
Thu Feb 1 02:43:59 EST 2007
On Feb 1, 2:36 pm, John Nagle <n... at animats.com> wrote:
> krypto.wiz... at gmail.com wrote:
> > Its not an homework. I appeared for EA sports interview last month. I
> > was asked this question and I got it wrong. I have already fidlled
> > around with the answer but I don't know the correct reasoning behind
> > it.
>
> The answer to that question is that the fastest way to divide
> by 7 is to use the divide instruction. You'd have to go down
> to a really old 8-bit microprocessor like the Intel 8051 to
> find something where bit-twiddling like that pays off.
Perhaps not that far back. Google "Granlund Montgomery". The technique
got built into gcc.
> And no way would this be a win in Python, which is
> interpreted.
Agreed.
More information about the Python-list
mailing list