一、数论算法
1.求两数的最大公约数
import sys
def gcd(p, q):
if q == 0: return p
return gcd(q, p%q)
def main():
p = int(sys.argv[1])
q = int(sys.argv[2])
print(gcd(p, q))
if __name__ == '__main__':
main()
import sys
def gcd(p, q):
if q == 0: return p
return gcd(q, p%q)
def main():
p = int(sys.argv[1])
q = int(sys.argv[2])
print(gcd(p, q))
if __name__ == '__main__':
main()
转载于:https://www.cnblogs.com/mocuishle/p/8476632.html