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
What is the difference between new and malloc functions?
What are two dimensional arrays alternatively called as?
What is include directive in c?
Are there any problems with performing mathematical operations on different variable types?
differentiate built-in functions and user – defined functions.
Does c have class?
What is spark map function?
Write a code to generate a series where the next element is the sum of last k terms.
What is calloc malloc realloc in c?
Is multithreading possible in c?
What is pointer in c?
What does c mean in basketball?
Write a C program in Fibonacci series.
How is a macro different from a function?
How to draw the flowchart for structure programs?