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.
There are 215 positive integers < 360 that cannot be so constructed.
The first three are 55, 57, 58.
The full list of "cannots" is
[55, 57, 58, 59, 79, 80, 91, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 139, 151, 153, 154, 155, 157, 158, 159, 161, 162, 163, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 187, 188, 189, 190, 191, 193, 194, 195, 196, 197, 198, 199, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 247, 248, 249, 250, 251, 253, 254, 255, 256, 257, 258, 259, 261, 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359]
------------
facs = [1,2,6,24,120]
answers = {}
for a in facs:
for b in facs:
for c in facs:
if c<a:
continue
for d in facs:
for e in facs:
if e<c:
continue
for f in facs:
x = a/b + c/d + e/f
if x%1 != 0:
continue
x = int(x)
if x not in answers:
answers[x] = [[a,b,c,d,e,f]]
else:
answers[x].append([a,b,c,d,e,f])
answerlist = sorted(answers.keys())
cannots = []
for ind,ans in enumerate(answerlist):
if ind == 0:
continue
if ans - answerlist[ind-1] != 1:
temp = [n for n in range(answerlist[ind-1]+1 , ans)]
for t in temp:
cannots.append(t)
print(sorted(list(set(cannots))))
print(len(cannots))
|
Posted by Larry
on 2024-11-26 18:00:08 |