Guest User

Untitled

a guest
Oct 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "math/bits"
  6. )
  7.  
  8. func main() {
  9. for i := uint64(0); i < 10; i++ {
  10. fmt.Printf("isPowerOfTwo(%d)=%v\n", i, isPowerOfTwo(i))
  11. }
  12. }
  13.  
  14. func isPowerOfTwo(n uint64) bool {
  15. return bits.OnesCount64(n) <= 1
  16. }
Add Comment
Please, Sign In to add comment