is_prime that consumes a Natural number(n) and returns True if n is prime (its only positive divisors are 1 and n), and False otherwise.
1条回答 默认 最新
- threenewbee 2020-01-20 09:06关注
# -*- coding: UTF-8 -*- def is_prime(n): if n < 2: return False if n == 2: return True for i in range(2, n / 2 + 1): if n % i == 0: return False return True for i in range(100): if (is_prime(i)): print(i)
如果问题得到解决,请点下
采纳
,谢谢合作解决 无用评论 打赏 举报
悬赏问题
- ¥15 overleaf中论文编辑,报错`pages' is a missing field, not a string, for entry 4
- ¥15 vhdl+MODELSIM
- ¥20 simulink中怎么使用solve函数?
- ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
- ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
- ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
- ¥15 知识蒸馏实战博客问题
- ¥15 用PLC设计纸袋糊底机送料系统
- ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
- ¥15 用C语言输入方程怎么