The fourth problem with the Euler project aims to find the largest palindrome generated by the product of three-digit numbers, a task which by inspection can be determined as something not easily done with pencil and paper by the product of three-digit numbers are generated 988200 results. Work to build the script to calculate all these results, select from there the 628 palindromes and find among these the largest, was not something a few minutes more, but not working on this problem a few days ago, I can say which were approximately 12 hours the whole I build this script that about 5 minutes (on my laptop) 906609 response yields the largest palindrome generated by the product of two three-digit numbers.
for i = 100:999% creates a square matrix P (ixn) with products of all figures x values \u200b\u200bfor n = 100:999
P (i, n) = i * n;
end
end for j = 1: length (P)% P Because finding a square matrix makes the matrix size
for q = 1: length (P)
if P (j, q) ~ = 0% does not start in 1 there are few zeros in P, are discarded
k = num2str (P (j, q)),% Convert each entry of P in a string
seqreverse if k == (k)% P compares each entry with your writing upside
% disp ( str2num (k)),% activate if you want to see a list of all palindromes
M (q ^ 2) = str2num (k);
Pm = max (M);
; end end end
end disp (Pm)