There is a ten-digit mystery number (no leading 0), represented by ABCDEFGHIJ, where each numeral, 0 through 9, is used once.
- A + B + C + D + E is a multiple of 6.
- F + G + H + I + J is a multiple of 5.
- A + C + E + G + I is a multiple of 9.
- B + D + F + H + J is a multiple of 2.
- AB is a multiple of 3.
- CD is a multiple of 4.
- EF is a multiple of 7.
- GH is a multiple of 8.
- IJ is a multiple of 10.
- FE, HC, and JA are all prime numbers.
Determine the number from the abovementioned clues.
digs=perms('1':'9');
names='abcdefghi';
for ii=1:length(digs)
set=digs(ii,:);
for j=1:9
cmd=[names(j) '=' set(j) ';'];
eval(cmd)
end
j=0;
if mod(a+c+e+g+i,9)==0
if mod(a+b+c+d+e,6)==0
if mod(f+g+h+i+j,5)==0
if mod(b+d+f+h+j,2)==0
if mod(10*a+b,3)==0
if mod(10*c+d,4)==0
if mod(10*e+f,7)==0
if mod(10*g+h,8)==0
if mod(10*i+j,10)==0
if isprime(10*f+e)
if isprime(10*h+c)
if isprime(10*j+a)
disp(set)
end
end
end
end
end
end
end
end
end
end
end
end
end
finds
5736912480
the zero at the end added by me; knowing j was zero (rule 9) saved much computing time.
|
Posted by Charlie
on 2023-10-05 15:05:41 |