We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e78a5b6 commit 06fcdb0Copy full SHA for 06fcdb0
ugly-number.go
@@ -0,0 +1,28 @@
1
+package main
2
+
3
+import (
4
+ "fmt"
5
+)
6
7
+func isUgly(num int) bool {
8
+ if num == 0 {
9
+ return false
10
+ }
11
+ if num == 1 {
12
+ return true
13
14
+ for num%2 == 0 {
15
+ num /= 2
16
17
+ for num%3 == 0 {
18
+ num /= 3
19
20
+ for num%5 == 0 {
21
+ num /= 5
22
23
+ return num == 1
24
+}
25
26
+func main() {
27
+ fmt.Println(isUgly(-2147483648))
28
0 commit comments