reference:
http://www.geeksforgeeks.org/multiply-an-integer-with-3-5/
Problem Definition:
Given a integer x, write a function that multiplies x with 3.5 and returns the integer result. You are not allowed to use %, /, *.
Examples:
Input: 2
Output: 7
Input: 5
Output: 17 (Ignore the digits after decimal point)
Solution:
This could be done by equation (8*x – x)/2 .
Code:
int multiplyWith3Point5(int x)
{
return ((x<<3) - x)>>1;
}