How many ways are there to choose integers a, b, and c such that 1 ≤ a < b < c ≤ 2024 and
a + b + c = 2027?
Using some analysis to limit the search parameters ...
extremes:
1,2,2024
674,676,677
1,1012,1014
a can be from 1 to 674
b can be from 2 to 1012
c can be from 677 to 1014
Program output: 341381
------------------
ct = 0
for a in range(1,675):
for b in range(a+1, 1013):
if a+b > 1351:
continue
c = 2027 - a - b
if c <= b:
continue
ct += 1
print(ct)
|
Posted by Larry
on 2024-12-16 19:02:38 |