Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math/bits"
- )
- func main() {
- for i := uint64(0); i < 10; i++ {
- fmt.Printf("isPowerOfTwo(%d)=%v\n", i, isPowerOfTwo(i))
- }
- }
- func isPowerOfTwo(n uint64) bool {
- return bits.OnesCount64(n) <= 1
- }
Add Comment
Please, Sign In to add comment