Find the three least positive integers that cannot be written as a!/b! + c!/d! + e!/f! for positive integers a,b,c,d,e,f less than or equal to 5.
had=[]; sets={};
clc
for a=1:5
af=factorial(a);
for c=a:5
cf=factorial(c);
for e=c:5
ef=factorial(e);
for b=1:5
for d=1:5
for f=1:5
t=factorial(a)/factorial(b)+factorial(c)/factorial(d)+factorial(e)/factorial(f);
if abs(round(t)-t)<.0001
disp([a b c d e f t])
had(end+1)=t;
sets{t}=[a b c d e f t]; end
end
end
end
end
end
end
unique(had)
% sets
setdiff(1:360,had)
for i=[1:54 56 60:78]
fprintf('%2d ',sets{i})
fprintf('\n')
end
finds that the first 7 that can't be expressed are
55 57 58 59 79 80 91
so the least three are 55, 57, and 58.
The possible totals, to 78, are
a b c d e f total
2 3 2 3 2 3 1
1 2 1 2 5 5 2
5 5 5 5 5 5 3
2 1 5 5 5 5 4
3 2 5 5 5 5 5
4 3 5 5 5 5 6
5 5 5 5 5 4 7
3 1 5 5 5 5 8
4 3 4 3 5 5 9
4 3 5 5 5 4 10
5 5 5 4 5 4 11
4 3 4 3 4 3 12
4 3 4 3 5 4 13
4 3 5 4 5 4 14
5 4 5 4 5 4 15
3 1 5 4 5 4 16
4 3 4 2 5 5 17
4 2 5 5 5 4 18
3 1 4 2 5 5 19
4 3 4 3 4 2 20
4 3 4 2 5 4 21
5 5 5 5 5 3 22
3 1 4 2 5 4 23
3 2 5 5 5 3 24
4 3 5 5 5 3 25
5 5 5 4 5 3 26
3 1 5 5 5 3 27
4 3 4 3 5 3 28
4 3 5 4 5 3 29
5 4 5 4 5 3 30
3 1 5 4 5 3 31
4 3 4 3 4 1 32
4 2 5 5 5 3 33
4 1 5 4 5 4 34
3 2 4 2 5 3 35
4 3 4 2 5 3 36
4 2 5 4 5 3 37
3 1 4 2 5 3 38
3 2 4 2 4 1 39
4 3 4 2 4 1 40
5 5 5 3 5 3 41
3 1 4 2 4 1 42
3 2 5 3 5 3 43
4 3 5 3 5 3 44
5 4 5 3 5 3 45
3 1 5 3 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