title: Create a method to find if a number is a power of 2?
body: <p>I have this code to return <code>true</code> if <code>num</code> is a power of 2. </p>
  
  <pre><code>def is_power_of_two?(num)
    result = num.inject(0) {|n1, n2| n2 ** n1}
    if result == num
      true
    else
      false
    end
  end
  
  p is_power_of_two?(16)
  </code></pre>
  
  <p>I keep getting an error though. How could I fix and simplify this code?</p>