MATLAB: How am i suppose to display the elements divisible to 5 from the Pythagorean theorem using numbers 1-50. every time i use the rem function i get a bunch of 0s and 1s. got this so far which only displays the Pythagorean theorem combinations from 1-5

pythagoreanrem function

n=1
for aa=1:50
for bb=aa+1:50
for cc=bb+1:50
if cc^2==aa^2 + bb^2
a(n)=aa;
b(n)=bb;
c(n)=cc;
n=n+1;
end
end
end
end
pythagorean=[a', b', c']

Best Answer

Add these lines at the end of your code
mask = all(rem(pythagorean,5) == [0 0 0], 2);
pythagorean = pythagorean(mask, :);