Charmaine has written down three 3-digit positive integers which between them contains exactly 9 distinct digits.
Among these three positive integers:
- There is at least one that is divisible by 2.
- There is at least one that is divisible by 3.
- There is at least one that is divisible by 4.
- There is at least one that is divisible by 5.
- There is at least one that is divisible by 6.
- There is at least one that is divisible by 7.
- There is at least one that is divisible by 8.
- There is at least one that is divisible by 9.
In addition, it is known that all the three positive integers are divisible by 11.
What are the three 3-digit integers posited by Charmaine?
Note: Adapted from Enigma # 1776 which appeared in 'New Scientist' in 2013.
clearvars,clc
allDigits='0123456789';
triples=combinator(10,3,'p');
triples=allDigits(triples);
for i=1:length(triples)-2
a=str2double(triples(i,:));
if mod(a,11)==0
for j=i+1:length(triples-1)
b=str2double(triples(j,:));
if mod(b,11)==0
for k=j+1:length(triples)
c=str2double(triples(k,:));
if mod(c,11)==0
divisible=zeros(1,9);
if length(unique([triples(i,:),triples(j,:),triples(k,:)])) ==9
for divr=2:9
if mod(a,divr)==0 || mod(b,divr)==0 || mod(c,divr)==0
divisible(divr)=1;
end
end
if isequal(divisible,[0,1,1,1,1,1,1,1,1])
disp([triples(i,:),' ',triples(j,:),' ',triples(k,:)])
end
end
end
end
end
end
end
end
finds
308 165 792
|
Posted by Charlie
on 2023-07-02 14:13:24 |