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

Appearance settings

Latest commit

 

History

History
History
13 lines (11 loc) · 556 Bytes

File metadata and controls

13 lines (11 loc) · 556 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
# -*- coding:utf-8 -*-
__author__ = 'gjw'
__time__ = '2018/1/5 0005 上午 10:37'
# 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。
# 程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。
for n in range(100,1000):
i = int(n / 100)
j = int(n / 10 % 10)
k = int(n % 10)
if n == i**3 + j**3 + k**3:
print(n)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.