设有两个数i,j:
其中i=p1^a1,*p2^a2*p3*a3*....*ps^as
j=p1^b1*p2^b2*p3^b3*.....*ps^bs
由算术基本定理得到:
gcd(i,j)=p1^min(a1,b1)*p2^min(a2,b2)*p3^min(a3,b3)*...*ps^min(as,bs)
lcm(i,j)=p1^max(a1,b1)*p2^max(a2,b2)*p3^max(a3,b3)*...*ps^max(as,bs)
设有两个数i,j:
其中i=p1^a1,*p2^a2*p3*a3*....*ps^as
j=p1^b1*p2^b2*p3^b3*.....*ps^bs
由算术基本定理得到:
gcd(i,j)=p1^min(a1,b1)*p2^min(a2,b2)*p3^min(a3,b3)*...*ps^min(as,bs)
lcm(i,j)=p1^max(a1,b1)*p2^max(a2,b2)*p3^max(a3,b3)*...*ps^max(as,bs)
转载于:https://www.cnblogs.com/JJsnow/p/10076579.html