Skip to content

Commit 906e1e1

Browse files
committed
Create 263. Ugly Number
Signed-off-by: Tahsin Tunan <[email protected]>
1 parent ee7a3bc commit 906e1e1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

go/0263-ugly-number.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
func isUgly(n int) bool {
2+
if n <= 0 {
3+
return false
4+
}
5+
6+
primes := []int{2, 3, 5}
7+
for _, p := range primes {
8+
for n%p == 0 {
9+
n /= p
10+
}
11+
}
12+
return n == 1
13+
}

0 commit comments

Comments
 (0)