Skip to content

Commit

Permalink
Merge pull request youngyangyang04#300 from betNevS/master
Browse files Browse the repository at this point in the history
添加 0202.快乐数 go版
  • Loading branch information
youngyangyang04 authored Jun 1, 2021
2 parents dc0359f + 659595f commit d2ab777
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions problems/0202.快乐数.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ Python:


Go:
```go
func isHappy(n int) bool {
m := make(map[int]bool)
for n != 1 && !m[n] {
n, m[n] = getSum(n), true
}
return n == 1
}

func getSum(n int) int {
sum := 0
for n > 0 {
sum += (n % 10) * (n % 10)
n = n / 10
}
return sum
}
```

javaScript:

Expand Down

0 comments on commit d2ab777

Please sign in to comment.