We can multiply a number by 7 using bit wise operator. First left shift the number by 3 bits (you will get 8n) then subtract the original number from the shifted number and return the difference (8n – n).
Program:
Time Complexity: O(1)
Space Complexity: O(1)
Note: Works only for positive integers.
[ad type=”banner”]