求2个数的最小公倍数和最大公约数

 1  # -*- coding: UTF-8 -*-
 2 
 3 def gongyueshu(m, n):
 4     if n == 0:
 5         return m
 6     else:
 7         return gongyueshu(n, m%n)
 8 
 9 def gongbeishu(m, n):
10     gongyue = gongyueshu(m, n)
11     return (m * n) / gongyue
12 
13 gong = gongyueshu(m=18, n=6)
14 print(gong)
15 gongbeishu=gongbeishu(34,43)
16 print(gongbeishu)

最大公约数肯定会小于等于2个值得差
原文地址:https://www.cnblogs.com/jingfuluo/p/5651946.html