def check_power(x) if x&(x-1)==0 print "#{x} is power of two" else print "#{x} is not power of two" end end check_power(126) # => 126 is not power of two check_power(1024) # => 1024 is power of two