- 计算最大公因数的Python代码
- 找出所有互质的数的Python代码
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
找出所有互质的数的Python代码
#Find all the numbers that are co-prime to a in range a
def all_coprime(a):
k=[]
for i in range(a):
if gcd(i,a)==1:
k.append(i)
i+=1
else:
i+=1
return k
全是自用学习笔记,自己查漏补缺用



