Python 最大公约数
2015-11-12 13:55
661 查看
代码:
num = int(raw_input("please input a data: "))
count = num/2
while count>0:
if num%count == 0:
print count, 'is the largest factor of', num
break;
count -=1
运行结果:
>>> ================================ RESTART ================================
>>>
please input a data: 51
17 is the largest factor of 51
num = int(raw_input("please input a data: "))
count = num/2
while count>0:
if num%count == 0:
print count, 'is the largest factor of', num
break;
count -=1
运行结果:
>>> ================================ RESTART ================================
>>>
please input a data: 51
17 is the largest factor of 51
相关文章推荐
- PEP8——Python代码规范
- python开发中range()函数用法实例分析
- python 线程同步
- Python生成excel文档
- python protobuf序列化repeated运用
- python开发中module模块用法实例分析
- python 学习笔记(08)
- Python中Class类用法实例分析
- python开发之函数定义实例分析
- python2.6升级2.7
- Python - 单步调试
- pip --upgrade批量更新过期的python库
- golang和python有关字符串操作的对应方法
- python连接mysql数据库
- python开发之字符串string操作方法实例详解
- Unofficial Windows Binaries for Python Extension Packages
- 深入浅析Python字符编码
- Python ping ip
- python开发之for循环操作实例详解
- python之print实践