Give a fast way to multiply a number by 7

Answer Posted / anonymous

The easiest way is to relate the number to be multiplied
by, to a power of 2. Then a corresponding number of left
shifts to that power with an addition or subtraction would
give the desired result.

In this case, 7 can be written as 2^3 - 1 or 8 - 1.
Therefore, shift the number to the left thrice which would
multiply it by 8. Then subtract the original. You can also
do this as

4 + 2 + 1 = 2^2 + 2^1 + 1

Is This Answer Correct ?    20 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

662


What is a memory leak? How to avoid it?

566


What is the use of a semicolon (;) at the end of every program statement?

764


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

643


What language is windows 1.0 written?

571






Why do we use pointer to pointer in c?

590


What are the 4 types of programming language?

576


Is c compiled or interpreted?

659


What are global variables and how do you declare them?

610


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1517


How are Structure passing and returning implemented by the complier?

707


What is difference between array and pointer in c?

534


Explain what is the benefit of using enum to declare a constant?

582


What is the difference between exit() and _exit() function in c?

578


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1895