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.
2 parents dc0359f + 659595f commit d2ab777Copy full SHA for d2ab777
problems/0202.快乐数.md
@@ -111,6 +111,24 @@ Python:
111
112
113
Go:
114
+```go
115
+func isHappy(n int) bool {
116
+ m := make(map[int]bool)
117
+ for n != 1 && !m[n] {
118
+ n, m[n] = getSum(n), true
119
+ }
120
+ return n == 1
121
+}
122
+
123
+func getSum(n int) int {
124
+ sum := 0
125
+ for n > 0 {
126
+ sum += (n % 10) * (n % 10)
127
+ n = n / 10
128
129
+ return sum
130
131
+```
132
133
javaScript:
134
0 commit comments