python 判断质数还是合数
2016-06-28 19:49
676 查看
while 1: s = input('请输入一个数:') s = int(s) if s == 2: print('质数') else: if s == 0 or s == 1: print('都不是') else: u = s - 2 h = 1 p = 1 while u: h = h + 1 if s % h == 0: p = 1 break else: p = 0 u = u - 1 if p: print('合数') else: print('质数')
相关文章推荐
- python中变长参数的用法举例?
- python27 windows 下三种安装第三方库的办法
- 基于Scrapy对更新后的Dmoz进行抓取(网上旧版本不靠谱)
- Python学习笔记(二):字典
- 深入理解Python中装饰器的用法
- python crawler - 抓取拉勾网职位信息
- windows下安装python,安装框架django。
- Python中的迭代器与生成器高级用法解析
- python学习笔记之面向对象编程特性(二)
- python 判断平年还是闰年
- Python3之sys模块
- Python作图-精确率与召回率间关系
- python ConfigParser、shutil、subprocess、ElementTree模块简解,configparser
- spark机器学习笔记:(三)用Spark Python构建推荐系统
- Python 之 地址簿程序
- Python设计足球联赛赛程表程序的思路与简单实现示例
- Python flask中的配置
- python 内嵌函数中,return调用函数的区别
- 详解Python中heapq模块的用法
- python flask中的代码约定