Hello,
I have a problem where I have to find possible squares in an array. For example [7 5 49] or [49 5 7] is true since 7 squared is 49, but [11 13 25] should return false.
Is there a way to do it better than a nested loop?
Thank you!
function y = isItSquared(x) y = false; for i = 1:length(x) for j = i+1:length(x) if x(i)^2 == x(j) || x(i) == x(j)^2 y = true break end end end
Best Answer