当前位置:编程学习 > 网站相关 >>

最大公约数 python表达

#!/usr/bin/env python  
def calGCD(op1, op2):  
    if (op2==0): return op1  
    else: return calGCD(op2, op1%op2)  
def calGCDAndLCM(op1, op2):  
    gcd = calGCD(op1, op2)  
    lcm = op1/gcd*op2  
    return (gcd, lcm)  
if __name__=='__main__':  
    op1 = int(raw_input('input the operands: '))  
    op2 = int(raw_input('input the operands: '))  
    result = calGCDAndLCM(op1, op2)  
    print result 

摘自 Z1Y7T的博客
补充:Web开发 , Python ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,