This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Piero Cimule
on 20 Jun 2020
M=[a,b,c,d]
c=nchoosek(M,3);
c=c(sum(c(:,1:2).^2,2)-c(:,3).^2==0,:);
if isempty(c)
flag = false;
else
flag = true;
end
Shuvo Kumar Paul
on 5 Aug 2020
function flag = isTherePythagoreanTriple(a, b, c, d)
flag = false;
com_bin = nchoosek([a b c d],3);
com_bin = com_bin(:,1) .^ 2 + com_bin(:,2) .^ 2 == com_bin(:,3) .^ 2;
flag = logical(sum(com_bin));
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!