Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Feb 19, 2024
1 parent e379dae commit 577b9a1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions leetcode/231.PowerofTwo/powerofTwo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// https://leetcode.com/problems/power-of-two

package main

import (
"fmt"
)

func isPowerOfTwo(n int) bool {
if n == 0 {
return false
}

for n%2 == 0 {
n /= 2
}

return n == 1
}

func main() {
n := 16

fmt.Print(isPowerOfTwo(n))
}

0 comments on commit 577b9a1

Please sign in to comment.