求一个数的最大公约数

2015-07-10 0 923
求一个数的最大公约数
__author__ = 'JanGin_Chan'
"'get the largest factor for the given non-prime number'"
number = raw_input('please input a number:\n')
num = int(number)
factor = num / 2
while factor > 1:
    if num % factor == 0:
        print '%s is the largest factor of the %s' % (factor,num)
        break
    factor -= 1
else:
    print 'the largest factor of %s is itself' % number

遇见资源网 python 求一个数的最大公约数 http://www.ox520.com/15603.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务