Find a rectangular prism whose edges and main diagonal have integer lengths, such that the squares of the edges are 10-digit pandigital numbers.
(In reply to
re: Computer solution by Charlie)
I had to change the code:
clearvars,clc
pandsr=[];
for i=31992:99380
% for i=11111:31426
i2=char(string(i^2));
if isequal(sort(i2),['0123456789'])
pandsr(end+1)=i;
end
end
fprintf(' %d',pandsr)
disp(' ')
l=length(pandsr);
for a=1:length(pandsr)
for b=a:length(pandsr)
for c=b:length(pandsr)
idx=[a b c];
dims=pandsr(idx);
diag=sqrt(sum(dims.^2));
if abs(diag-round(diag))<.01
dims=vpa(dims);
diag=sqrt(sum(dims.^2));
if abs(diag-round(diag))<.00001
disp([dims diag])
end
end
end
end
end
producing
[35853.0, 40545.0, 59403.0, 80361.999993778153853570646764205]
[40545.0, 40545.0, 40545.0, 70225.999992880129866070311916356]
[45624.0, 91248.0, 91248.0, 136872.0]
[55446.0, 76182.0, 78072.0, 122364.99999591386425850244553059]
[62679.0, 87639.0, 89079.0, 139801.00000715302465629299589512]
The same approximations as before plus the solution, now that duplicates were allowed in the dimensions.
|
Posted by Charlie
on 2023-10-18 16:08:39 |