Find all possible triplet of positive integers (a, b, c) that satisfy this system of equations:
(GCD(a,b))^2= a+b
(GCD(b,c))^2= b+c
(GCD(c,a))^2 = c+a
pairs=double.empty(0,2);
for a=1:2000
if mod(a,100)==0
disp(a)
end
for b=a:2000
if gcd(a,b)^2==a+b
pairs(end+1,:)=[a,b];
if a~=b
pairs(end+1,:)=[b,a];
end
end
end
end
pairs=sortrows(pairs,1);
writematrix(pairs);
clc
for aptr=1:length(pairs)
a=pairs(aptr,1);
b=pairs(aptr,2);
cptr=find(pairs(:,1)==b);
for i=1:length(cptr)
c=pairs(cptr(i),2);
if gcd(c,a)^2==c+a
if a~=b && b~=c && a~=c
flag="***";
else
flag=" ";
end
fprintf('%5d %5d %5d %s\n',a,b,c,flag)
end
end
end
finds only (2,2,2)
|
Posted by Charlie
on 2023-12-14 08:11:43 |