Thread: multiply by 7

  1. #1
    Registered User
    Join Date
    Oct 2005
    Hyderabad, India

    multiply by 7

    how will you multiply a positive number by 7 without using straight forward multiplication and addition.

    best i could find out was
    int func(int n){
    int temp = n<<3; //multiply by 8
    return temp - n;
    any more interesting ways of solving this (i don't want subtraction either ???)

  2. #2
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Cayman Islands
    int times7(int num)
        return num/0.142857;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiply sections of printf format specifier?
    By space_ferret in forum C Programming
    Replies: 14
    Last Post: 03-27-2009, 10:54 AM
  2. Multiply using Bitwise
    By ganesh bala in forum C Programming
    Replies: 3
    Last Post: 01-29-2009, 11:35 PM
  3. multiply link list
    By mradul.exe in forum C Programming
    Replies: 5
    Last Post: 07-12-2008, 07:18 PM
  4. open file with numbers and multiply them
    By autopilot in forum C Programming
    Replies: 30
    Last Post: 09-10-2007, 04:48 PM
  5. How to multiply and Divide Huge int numbers
    By Dewayne in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 08:41 PM
Website Security Test