title: Another method to multiply two numbers without using the "*" operator
body: <p>I had an interesting interview yesterday where the interviewer asked me a classic question: How can we multiply two numbers in Java without using the <code>*</code> operator. Honestly, I don't know if it's the stress that comes with interviews, but I wasn't able to come up with any solution.</p>
  
  <p>After the interview, I went home and breezed through SO for answers. So far, here are the ones I have found:</p>
  
  <p><strong>First Method</strong>: Using a For loop</p>
  
  <pre><code>// Using For loop
  public static int multiplierLoop(int a, int b) {
      int resultat = 0;
      for (int i = 0; i &lt; a; i++) {
          resultat += b;
      }
  
      return resultat;
  }
  </code></pre>
  
  <p><strong>Second Method</strong>: Using Recursion</p>
  
  <pre><code>// using Recursion
  public static int multiplier(int a, int b) {
  
      if ((a == 0) || (b == 0))
          return 0;
      else
          return (a + multiplier(a, b - 1));
  
  }
  </code></pre>
  
  <p><strong>Third Method</strong>: Using Log10</p>
  
  <pre><code>**// Using Math.Log10
  public static double multiplierLog(int a, int b) {
      return Math.pow(10, (Math.log10(a) + Math.log10(b)));
  }**
  </code></pre>
  
  <p>So now I have two questions for you:</p>
  
  <ol>
  <li>Is there still another method I'm missing? </li>
  <li>Does the fact that I wasn't able to come up with the answer proves that my logical reasoning isn't strong enough to come up with solutions and that I'm not "cut out" to be a programmer? Cause let's be honest, the question didn't seem that difficult and I'm pretty sure most programmers would easily and quickly find an answer.</li>
  </ol>