@@ -0,0 +1,10 @@
+func addDigits(num int) int {
+ if num == 0 { // If sum of digits is divisable by 9, then num is divisable by 9.
+ // In fact, (num % 9) == [sum of digits] % 9
+ return 0
+ } else if n := nums % 9; n == 0 {
+ return 9
+ } else {
+ return n
+ }
+}
@@ -0,0 +1,16 @@
+func isUgly(num int) bool {
+ if num <= 0 {
+ return false
+ for num & 1 == 0 {
+ num >>= 1
+ for num % 5 == 0 {
+ num /= 5
+ for num % 3 == 0 {
+ num /= 3
+ return num == 1
+