title: ruby bitwise product
body: <p>I've got an assignment where I have had to write a function, which takes two integers and returns it's bitwise product. Bitwise product equals to bitwise sum (<code>&amp;</code>) of all numbers between these two.</p>
  <p>For example: bitwise product of <code>251</code> and <code>253</code> is:</p>
  <pre><code>irb(main):164:0&gt; 251 &amp; 252
  =&gt; 248
  irb(main):165:0&gt; 252 &amp; 253
  =&gt; 252
  irb(main):166:0&gt; 248 &amp; 252
  =&gt; 248 # this a bitwise &amp; of these two between 251 &amp; 253
  </code></pre>
  <p>My function:</p>
  <pre><code>def solution(m,n)
    (m..n).to_a.inject{|sum, x| sum &amp;= x}
  end
  </code></pre>
  <p>Test:</p>
  <pre><code>irb(main):160:0&gt; (251..253).to_a.inject{|sum, x| sum &amp;= x}
  =&gt; 248 #same result
  </code></pre>
  <p>The program's evaluation:</p>
  <blockquote>
  <p>correctness 100%<br />
  performance 0%</p>
  </blockquote>
  <p>Can anyone, please explain what is with performance of this function? Thanks in advance!</p>
  <h1>EDIT</h1>
  <p>Since <em>performance</em> is undefined here, can you provide an analysis of the function for, for example, really big inputs and criticise/suggest better/more efficient solution?</p>
  <p>p.s. thx for comments guys, i will follow the recommendations!</p>