Hi, this is Shunchi!

  • Home

  • Tags0

  • Archives267

  • Categories0

  • Curricula

  • DSA

  • LeetCode_Notes

  • Interviews

  • General

  • Resume

Determine if a number is 2 to the power of n

Posted on 2020-05-02 | Edited on 2020-05-03 | Comments:

Determine if a number is 2 to the power of n

1
2
3
boolean IsPowerOfTwo(ulong x) {
return (x != 0) && ((x & (x - 1)) == 0);
}

<1…238239240…267>
ShunchiZhou

ShunchiZhou

267 posts
RSS
GitHub E-Mail Gitbook Linkedin
© 2024 ShunchiZhou
Powered by Hexo v5.4.0
|
0%