Jeffie Foodlemyer needs to hire an accountant. Three people apply for the job. He decides to use a mathematical puzzle to test each accountant's numeric skills. He chooses 4 integers greater than 1, and tells the first applicant their product. The accountant immediately tells him the 4 numbers. Too easy.
He tells the second applicant the sum of the squares of the 4 numbers. Again, the accountant tells him the 4 numbers immediately. Still too easy.
So he tells the last applicant the product of the 3 smallest numbers plus twice the square of the largest number. That accountant is unable to tell him the 4 numbers. Note that, he interviews the 3 accountants separately.
What 4 numbers did he choose?
clc
c=combinator(200,4,'c');
sqs=c.^2;
for i=1:length(sqs)
sums(i)=sum(sqs(i,:));
end
[sumsort,idx]=sort(sums);
if sumsort(1)~=sumsort(2)
disp([sumsort(1),c(idx(1),:)])
end
for i=2:length(sumsort)-1
if sumsort(i)~=sumsort(i-1) && sumsort(i)~=sumsort(i+1)
set=c(idx(i),:);
good=true;
for j=1:4
if ~isprime(set(j))
good=false;
end
end
if good
disp([sumsort(i),set])
end
end
end
finds
87 2 3 5 7
628 7 11 13 17
plus many larger amounts that are probably unique only because the search was only up to 200.
These represent unique totals of four prime numbers whose sums of squares are also unique sums of squares, even disregarding their being prime. They need to be prime so that the first applicant would recognize that fact and see that the factorization was the answer.
If the first line is the one chosen, then the last applicant was told 2*3*5+98 = 128. If the second line, then 7*11*13+2*17^2 = 1579.
While 1579 is unique among the possibilities for the last accountant, 128 has multiple solutions according to what he was told:
128 1 5 6 7
128 2 3 5 7
1579 7 11 13 17
If the last accountant was unable to solve his problem due to it being insoluble, the four numbers are 2, 3, 5 and 7. But if the question was a legitimate one and the last applicant just didn't have the ability, they were 7, 11, 13 and 17.
Program extension for this last part:
for i=1:length(c)
cp=c(i,:);
large= find(cp==(max(cp)));
cp(large)=[];
v=prod(cp)+2*c(i,large)^2;
if v==128 || v == 1579
disp([v,c(i,:)])
end
end
|
Posted by Charlie
on 2024-03-08 11:07:50 |