This solution is outdated. To rescore this solution, sign in.
-
1 Comment
Muhammet Fatih isik
on 14 May 2021
hi, my cod gives me true ans but its worked too slow because of for loop but could not figure it out without for loop. could u send me our code or check mines ? function u = euler004(n)
function L = ispalindrome(n)
s=num2str(n);
l=length(s);
for i=1:ceil(l/2)
if str2double(s(i)) == str2double(s(l-i+1))
continue
else
L=false;
return
end
end
L=true;
end
c=numel(num2str(n));
switch c
case 3
l=9;
case 4
l=99;
end
g=l:n;
m=l:n;
z=g'*m;
b=z(:)';
T=[];
for vz=1:numel(b)
if ispalindrome(b(vz))>0
T=b(vz);
end
end
u=max(T);
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!