Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65b5004

Browse files
authored
Happy Number
1 parent5cdb749 commit65b5004

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎202. Happy Number/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Solution
2+
```
3+
class Solution:
4+
def isHappy(self, n):
5+
di = dict()
6+
while True:
7+
k = 0
8+
while n > 0:
9+
k += (n % 10) ** 2
10+
n = n // 10
11+
if k == 1:
12+
return True
13+
if k in di:
14+
return False
15+
else:
16+
di[k] = 1
17+
n = k
18+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp