Multiply by 7 Without *
How to multiply by seven manually is an easy quant interview question on Algorithms.
This interview question asks for a way to multiply an integer by a fixed small constant using only simpler operations, explicitly excluding the usual multiplication operator. The setup is purely algorithmic: design a procedure that takes an integer input and outputs the product with a fixed factor, expressed in terms of operations that are typically cheap at the machine level. It is common in software engineering and quantitative development screens where low-level understanding of integer arithmetic, bitwise operations, and performance-aware coding are relevant.
The core ideas involved are binary representation of integers, decomposition into powers of two, and the equivalence between multiplying by powers of two and left-shifting. Candidates are expected to translate an arithmetic identity into an implementation using shifts, additions, or subtractions, while preserving correctness for all integers in the chosen range. Interviewers watch for clarity in reasoning from number theory to bit operations, awareness of edge cases such as negative values or overflow, and the ability to express the method cleanly in code or pseudocode without relying on forbidden operators.
What it tests
Any integer multiplication can be decomposed into a sum or difference of powers of two times the integer, leveraging the binary representation of numbers. This is because every integer can be written as a sum of distinct powers of two, and multiplying by a power of two is equivalent to a left bit-shift. Thus, multiplying by a constant $k$ can be achieved by expressing $k$ as a sum or difference of powers of two, then applying the corresponding shifts and additions/subtractions. This approach is foundational in computer arithmetic and underlies efficient algorithms for multiplication in hardware and software. The reason this works is that binary arithmetic aligns perfectly with the structure of digital computation, making shifts and adds much cheaper than general multiplication.
Practise this question with written feedback, or hear it in a spoken mock interview.
Get started free