Problem 235. Project Euler: Problem 4, Palindromic numbers
Solution Stats
Problem Comments
-
3 Comments
Your last test case is accidentally all commented out, so isn't a real test case
The question is unclear. Do the factor-numbers all have to be two-digited?
@Jan-Andrea Bard, no.
Although it is not mentioned clearly in the problem statement but you can see a hint from the test suite
Solution Comments
-
2 Comments
Sorry for cheating but I couldn't find a solution that doesn't crash the servers
A double for loop that performs a brute force scan from x down to 0.9*x in each loop - doesn't crash the servers :)
-
1 Comment
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
-
1 Comment
can anyone explain what is meaning of products of two inputs ,here input is only one number ,does it mean the square of input
-
2 Comments
? cheat
More like exploiting the limited test suite by hard coding. The test suite has been updated now.
-
4 Comments
Cheating ...
Thanks for the note Aurelien. I added to the test suite.
the largest palindrome made from the product of 9999 is 99977999, not 99000099!
and x=999,y=997799, not 906609.
x=2500, y=6249246, not 6167616
x=100, y=999, not 9009
zd c, 99977999 cannot be written as the product of two numbers less than or equal to 9999.
-
1 Comment
Size 42 ! wow should be the best solution
Problem Recent Solvers747
Suggested Problems
-
Implement simple rotation cypher
1031 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
823 Solvers
-
Fahrenheit to Celsius converter
482 Solvers
-
The sum of the numbers in the vector
532 Solvers
-
Find out sum and carry of Binary adder
966 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!