Multiply with power of 2 without using pow() or * operator

Objective: Given a number n and k, Calculate n * k2 without using pow() or *operator.


N = 3, k = 4
N*k2 = 48

Approach: Bit Manipulation

Left shift the number N by k.

For example, N = 3
Bit representation: 0 1 1
Left shift by k = 4
0 1 1 0 0 0 0 which is the representation of 48.

Java Code:


Number 3 Multiplied by 2^4 is: 48

Also Read about –

Top Companies Interview Questions..-


If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: