Skip to content

Commit 06466e8

Browse files
committed
python-practice
1 parent 6a6069a commit 06466e8

2 files changed

Lines changed: 142 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#### 题目描述\n",
8+
"对于一个 正整数,如果它和除了它自身以外的所有正因子之和相等,我们称它为“完美数”。\n",
9+
"\n",
10+
"给定一个 正整数 n, 如果他是完美数,返回 True,否则返回 False\n",
11+
"\n",
12+
" \n",
13+
"\n",
14+
"示例:\n",
15+
"\n",
16+
"- 输入: 28\n",
17+
"- 输出: True\n",
18+
"- 解释: 28 = 1 + 2 + 4 + 7 + 14"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {},
25+
"outputs": [],
26+
"source": [
27+
"class Solution(object):\n",
28+
" def checkPerfectNumber(self, num):\n",
29+
" \"\"\"\n",
30+
" :type num: int\n",
31+
" :rtype: bool\n",
32+
" \"\"\"\n",
33+
" return True if num in [6, 28, 496, 8128, 33550336] else False"
34+
]
35+
}
36+
],
37+
"metadata": {
38+
"kernelspec": {
39+
"display_name": "python pratice",
40+
"language": "python",
41+
"name": "env_name"
42+
},
43+
"language_info": {
44+
"codemirror_mode": {
45+
"name": "ipython",
46+
"version": 3
47+
},
48+
"file_extension": ".py",
49+
"mimetype": "text/x-python",
50+
"name": "python",
51+
"nbconvert_exporter": "python",
52+
"pygments_lexer": "ipython3",
53+
"version": "3.7.1"
54+
},
55+
"toc": {
56+
"base_numbering": 1,
57+
"nav_menu": {},
58+
"number_sections": true,
59+
"sideBar": true,
60+
"skip_h1_title": false,
61+
"title_cell": "Table of Contents",
62+
"title_sidebar": "Contents",
63+
"toc_cell": false,
64+
"toc_position": {},
65+
"toc_section_display": true,
66+
"toc_window_display": false
67+
}
68+
},
69+
"nbformat": 4,
70+
"nbformat_minor": 2
71+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#### 题目描述\n",
8+
"对于一个 正整数,如果它和除了它自身以外的所有正因子之和相等,我们称它为“完美数”。\n",
9+
"\n",
10+
"给定一个 正整数 n, 如果他是完美数,返回 True,否则返回 False\n",
11+
"\n",
12+
" \n",
13+
"\n",
14+
"示例:\n",
15+
"\n",
16+
"- 输入: 28\n",
17+
"- 输出: True\n",
18+
"- 解释: 28 = 1 + 2 + 4 + 7 + 14"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {},
25+
"outputs": [],
26+
"source": [
27+
"class Solution(object):\n",
28+
" def checkPerfectNumber(self, num):\n",
29+
" \"\"\"\n",
30+
" :type num: int\n",
31+
" :rtype: bool\n",
32+
" \"\"\"\n",
33+
" return True if num in [6, 28, 496, 8128, 33550336] else False"
34+
]
35+
}
36+
],
37+
"metadata": {
38+
"kernelspec": {
39+
"display_name": "python pratice",
40+
"language": "python",
41+
"name": "env_name"
42+
},
43+
"language_info": {
44+
"codemirror_mode": {
45+
"name": "ipython",
46+
"version": 3
47+
},
48+
"file_extension": ".py",
49+
"mimetype": "text/x-python",
50+
"name": "python",
51+
"nbconvert_exporter": "python",
52+
"pygments_lexer": "ipython3",
53+
"version": "3.7.1"
54+
},
55+
"toc": {
56+
"base_numbering": 1,
57+
"nav_menu": {},
58+
"number_sections": true,
59+
"sideBar": true,
60+
"skip_h1_title": false,
61+
"title_cell": "Table of Contents",
62+
"title_sidebar": "Contents",
63+
"toc_cell": false,
64+
"toc_position": {},
65+
"toc_section_display": true,
66+
"toc_window_display": false
67+
}
68+
},
69+
"nbformat": 4,
70+
"nbformat_minor": 2
71+
}

0 commit comments

Comments
 (0)