for n in range(400,500): i=n//100 j=n//10%10 k=n%10 if n==i**3+j**3+k**3: print(n)
时间: 2023-12-31 11:06:12 浏览: 57
This code is written in Python and finds all the three-digit numbers between 400 and 500 that are equal to the sum of the cubes of their digits.
Here is how the code works:
- The for loop runs through all the numbers between 400 and 500 (inclusive) using the range function.
- The // operator is used to perform integer division, which gives the hundreds digit of the number (i), the tens digit of the number (j), and the ones digit of the number (k).
- The if statement checks whether the original number (n) is equal to the sum of the cubes of its digits (i**3 + j**3 + k**3). If it is, the number is printed.
So, the output of this code will be a list of three-digit numbers that are equal to the sum of the cubes of their digits between 400 and 500.
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)