division by 7 efficiently



Last month I appeared for an interview with EA sports and they asked
me this question.

How would you divide a number by 7 without using division operator ?

I did by doing a subtraction and keeping a counter that kept a tab on
how many times I subtracted.

Later, the EA sport guy told me that of course there are can be better
technique by using bit operator.

Since 7 has a binary representation 111, my guess is that a left shift
operation of 3 bits should give the answer, but I couldn't get it to
work.

Any comments ?

.



Relevant Pages

  • Re: division by 7 without using division operator
    ... Last month I appeared for an interview with EA sports and they ... How would you divide a number by 7 without using division operator? ... I did by doing a subtraction and keeping a counter that kept a tab ...
    (comp.lang.c)
  • division by 7efficiently
    ... Last month I appeared for an interview with EA sports and they asked ... How would you divide a number by 7 without using division operator? ... I did by doing a subtraction and keeping a counter that kept a tab on ...
    (comp.theory)
  • division by 7
    ... Last month I appeared for an interview with EA sports and they asked ... How would you divide a number by 7 without using division operator? ... I did by doing a subtraction and keeping a counter that kept a tab on ...
    (sci.math)
  • division by 7 without using division operator
    ... Last month I appeared for an interview with EA sports and they asked ... How would you divide a number by 7 without using division operator? ... I did by doing a subtraction and keeping a counter that kept a tab on ...
    (comp.lang.c)
  • Re: division by 7 efficiently
    ... How would you divide a number by 7 without using division operator? ... I did by doing a subtraction and keeping a counter that kept a tab on ... could call it the "caveman" method, ...
    (comp.programming)