num = 100
while num <= 999:
a = num % 10 #取个位数
b = num // 10 % 10 #取十位数
c = num // 100 #取百位数
if num == a**3 + b**3 + c**3:
print (num)
num += 1 #python不支持 num++ 之类的写法

Python输出三位数以内的水仙花数的更多相关文章

  1. 使用js输出1000以内的水仙花数

    什么是水仙花数 水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI).自恋数.自幂数.阿姆斯壮数或阿姆斯特 ...

  2. Python常见面试(习题)——水仙花数

    今天,给大家分享一个习题. 用python输出100到1000以内的水仙花数. 相信很多小伙伴都听到过,或者遇到过这个题目. 那么今天就来带大家做一做这道题. 首先,我们要知道什么是水仙花数, (@_ ...

  3. 【C语言】创建一个函数,判断某一正整数是否为水仙花数,并调用这个函数找出1000以内所有水仙花数

    #include <stdio.h> int fun(int x) { int a, b, c; a = x / ; b = x % / ; c = x % ; if (x == a * ...

  4. Demo02一千以内的水仙花数

    package 习题集2;//1000以内的水仙花数public class Demo02 { public static void main(String[] args) { int i = 100 ...

  5. JS 1000以内的水仙花数 (三位数 各个数字的立方和等于本身 例如 1*1*1 + 5*5*5 + 7*7*7 = 157)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. java求1000以内的水仙花数

    水仙花数是指一个 n 位数 ( n>=3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153) 三位的水仙花数共有4个,分别为:153.370. ...

  7. 【C语言】找出1000以内的水仙花数

    什么是水仙花数? 水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153). 代码1: #include<stdio.h> ...

  8. 【C语言】(for循环嵌套)找出1000以内的水仙花数

    什么是水仙花数? 水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153). 分析: 根据定义可知: a*a*a+b*b*b+c*c*c ...

  9. PHP水仙花数的实现

    php水仙花数是什么? 水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153)三位的水仙花数共有4个:153,3 ...

随机推荐

  1. 【Hibernate 多表查询】

    HibernateManyTable public class HibernateManyTable { //演示hql左连接查询 @Test public void testSelect12() { ...

  2. C 语言实例 -求分数数列1/2+2/3+3/5+5/8+...的前n项和

    程序分析:抓住分子与分母的变化规律:分子a:1,2,3,5,8,13,21,34,55,89,144...分母b:2,3,5,8,13,21,34,55,89,144,233...分母b把数赋给了分子 ...

  3. 细说unittest

    一.unittest模块官方文档: https://docs.python.org/3/library/unittest.html 二.一张图看懂unittest: 三.Unittest主要方法属性: ...

  4. 登录oracle ORA-12541: TNS:no listener报错

    初次安装Oracle是通过VMware在虚拟机上安装的,安装Oracle过程,解锁了两个用户,分别是Scott和HR,也设置了密码,安装完成后输入sqlplus scott/admin123(scot ...

  5. Vacuum Pump Manufacturer - Vacuum Pump: Prevents Reactive Compound Decomposition Products

    Vacuum packaging has been popular in the industry for a long time. Many large companies have joined ...

  6. JDBC 获取自动生成的主键

    为什么需要获取自动生成的主键 例如:

  7. Bugku - CTF加密篇之滴答~滴

    滴答~滴 答案格式KEY{xxxxxxxxx}

  8. Newtonsoft.Json小记

    /*json相关*/ //http://www.cnblogs.com/hongfei/p/3593936.html string jsonObject = "{\"phone\& ...

  9. Deepin-linux下的linux的终端下软件安装和卸载方法

    1.方法一: sudo apt update #最好第一步是它 sudo apt install <package_name> --no-upgrade #安装该package但是不升级. ...

  10. Vue项目的准备

    1.下载nodejs 检查是否安装成功 2.使用gitee作为线上仓库 3.使用脚手架工具--命令行工具 能在8080里显示出以下画面即为成功