# Want to know what Ruby n is the power of 2? (Power judgment of 2)

# What is exponentiation in the first place?

To put it simply, is n a number that is a sham of 2?
How is it? tell me~~
That
No, it ’s really too appropriate and I ’m going to get angry.
Click here for details.

https://atarimae.biz/archives/20521

# Click here for the judgment formula

`bekijyo.rb`

```
if (n&(n-1)) == 0 then
puts "Power of 2"
else
puts "Not a power of 2"
end
```

# Background of posting

I didn't know "exponentiation" in the first place, so I made a great detour.
It's a uselessly complicated formula, but from the middle
"There is a judgment formula that can be solved in one shot."
It's already a haguri festival.

That's why it's difficult to go through without knowing the words,
It depends on whether you can get there, but if it helps someone.

that's all.
I bruised.