29 April, 2011

Efficient way

How to fast multiply a number by 7?

1 comment:

  1. Left shift the number 3 times which we have to multiply with 7 and then subtract the original number from the sifted number. The final number is the result of multiplication.
    For example:

    Take number 9 which we have to multiply by 7.
    code for this is

    int main(void)
    {
    int number = 9;
    int result = 0;

    result = number;
    result = (number << 3) - result;

    printf("The multiplication result is %d\n",result);

    return 0;
    }

    The output of this code is 63.

    ReplyDelete