当前位置:网站首页>实例036:算素数
实例036:算素数
2022-08-04 01:35:00 【懒笑翻】
题目:求100之内的素数。
程序分析:用else执行for循环的奖励代码(如果for是正常完结,非break)。
代码:
lo = int(input('下限:'))
hi = int(input('上限:'))
for i in range(lo, hi + 1):
if i > 1:
for j in range(2, i):
if (i % j) == 0:
break
else:
print(i, end=' ')
"""
* @Author: xiaofang
* @Description:
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,扫码下方QQ群二维码即可
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""结果:

边栏推荐
- C # WPF equipment monitoring software (classic) - the next
- 一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
- Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
- jmeter跨平台运行csv等文件
- 字符串变形
- 观察者模式
- Analysis of usage scenarios of mutex, read-write lock, spin lock, and atomic operation instructions xaddl and cmpxchg
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- lombok注解@RequiredArgsConstructor的使用
猜你喜欢

Installation and configuration of nodejs+npm

LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之三:两次优化

企业虚拟偶像产生了实质性的价值效益

Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud

nodejs+express实现数据库mysql的访问,并展示数据到页面上

OpenCV如何实现Sobel边缘检测

如何用C语言代码实现商品管理系统开发

【OpenCV】-重映射

持续投入商品研发,叮咚买菜赢在了供应链投入上

循环绕过问题
随机推荐
JS 从零教你手写节流throttle
boot issue
Installation and configuration of nodejs+npm
jmeter分布式压测
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
.NET Static Code Weaving - Rougamo Release 1.1.0
How to find the cause of Fiori Launchpad routing errors by single-step debugging
Slipper - virtual point, shortest path
html select标签赋值数据库查询结果
typescript56 - generic interface
Array_Sliding window | leecode brushing notes
nodejs安装及环境配置
Flask框架初学-05-命令管理Manager及数据库的使用
2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
LDO investigation
Promise 解决阻塞式同步,将异步变为同步
Promise solves blocking synchronization and turns asynchronous into synchronous
持续投入商品研发,叮咚买菜赢在了供应链投入上