博客
关于我
python学习12:水仙花
阅读量:305 次
发布时间:2019-03-03

本文共 405 字,大约阅读时间需要 1 分钟。

'''求101-999中的水仙花数,水仙花数,个十百三数的立方相加等于本身'''from builtins import rangedef test1():    for i in range(101,1000):        g=i%10        s=int(i/10)%10        b=int(i/100)        if i==g**3+s**3+b**3:            print(i)def test2():    for i in range(101,1000):        st=str(i)        g=int(st[2])        s=int(st[1])        b=int(st[0])        if i==g**3+s**3+b**3:            print(i)            test1()test2()

转载地址:http://fnym.baihongyu.com/

你可能感兴趣的文章
NewspaceGPT绘制时序图
查看>>
new一个对象的过程
查看>>
new和delete用法小结
查看>>
new对象时,JVM内部究竟藏了什么小秘密?
查看>>
new操作符的实现原理
查看>>
Next.js React Server Components 教程
查看>>
NextGen Mirth Connect XStream反序列化远程代码执行漏洞(CVE-2023-43208)
查看>>
next项目部署到服务器pm2进程守护
查看>>
nexus 介绍
查看>>
nexus上传jar
查看>>
Nexus指南中的更新强调集成和透明度的重要性
查看>>
Nexus指南已经发布
查看>>
Nexus(1):Nexus的安装与配置
查看>>
NFC技术:概述
查看>>
NFinal学习笔记 02—NFinalBuild
查看>>
NFS
查看>>
nfs mount 故障 mount.nfs: access denied by server while mounting 10.0.100.208:/backup_usb
查看>>
NFS Server及Client配置与挂载详解
查看>>
NFS 服务配置篇
查看>>
NFS共享文件系统搭建
查看>>