Suppose that a positive integer N can be expressed as the sum of k consecutive
positive integers
N = a + (a + 1) + (a + 2) + · · · + (a + k − 1)
for k = 2017 but for no other values of k > 1.
Considering all positive integers N
with this property, what is the smallest positive integer a that occurs in any of these
expressions?
Source: Putnam 2017
I believe this is what is sought:
Start with a. Compute N(a, 2017). Then for k from 2 to 2016 see if there is a value of 'b' s.t. N(b,k) = N(a, 2017). Then if checking every k from 2 to 2016 there is no integer value of b, then we have found a solution.
For example, suppose a=1 and k=2017 Then N=2035153, but this value of a fails because:
N=2035153 works for other (a,k) pairs in addition to (1, 2017): specifically (1513, 1009), and (1017576, 2)
So a cannot be 1.
---
N(a,k) = ak + (k)(k-1)/2
Given N, find 'b' values such that for some k, N(b,k) = N(a,2017)
value for b = N/k - (k-1)/2
The first several values for a: [16, 1040, 3088, 7184, 15376, 31760, 64528]
(which is not in oeis)
So the smallest such value for a = 16
------------------------
def f(a,k):
return a*k + (k)*(k-1)/2
def find_a(N,k):
""" k^2 + (2a-1)k - 2N = 0 """
return N/k - (k-1)/2
ans = []
power = 5
for a in range(1,10**power):
found = False
this_n = f(a,2017)
for k in range(2, 2017):
b = find_a(this_n,k)
if b%1 == 0:
found = True
if not found:
print(a)
ans.append(a)
Edited on March 9, 2024, 12:20 pm
|
Posted by Larry
on 2024-03-09 12:18:02 |