代码拉取完成,页面将自动刷新
def gcd(a,b):
if b == 0:
return a
else:
return gcd(b,a%b)
def ngcd(xlist,n):
if n == 1:
return xlist[0]
else:
return gcd(xlist[n-1],ngcd(xlist,n-1))
def lcm(a,b):
return a*b/gcd(a,b)
def nlcm(xlist,n):
if n == 1:
return xlist[0]
else:
return lcm(xlist[n-1],nlcm(xlist,n-1))
n = int(input("请输入要输入数字的个数:"))
print("请输入{}个数字".format(n))
xlist = []
for i in range(0,n):
x = int(input())
xlist.append(x)
print("最大公约数为{},最大公倍数为{}".format(ngcd(xlist,n),nlcm(xlist,n)))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。