Investigating Ulam Sequences

For two positive integers $a$ and $b$, the Ulam sequence $U(a,b)$ is defined by $U(a,b)_1 = a$, $U(a,b)_2 = b$ and for $k \gt 2$,
$U(a,b)_k$ is the smallest integer greater than $U(a,b)_{k – 1}$ which can be written in exactly one way as the sum of two distinct previous members of $U(a,b)$.
For example, the sequence $U(1,2)$ begins with
$1$, $2$, $3 = 1 + 2$, $4 = 1 + 3$, $6 = 2 + 4$, $8 = 2 + 6$, $11 = 3 + 8$;
$5$ does not belong to it because $5 = 1 + 4 = 2 + 3$ has two representations as the sum of two previous members, likewise $7 = 1 + 6 = 3 + 4$.
Find $\sum U(2,2n+1)_k$ for $2 \le n \le 10$, where $k = 10^{11}$.

To solve this problem, we can use Python programming to generate the Ulam sequence and calculate the required sum. Here’s the Python code:

def ulam_sequence(a, b, k):
sequence = [a, b]
while len(sequence) < k: sums = {} for i in range(len(sequence)-1): for j in range(i+1, len(sequence)): s = sequence[i] + sequence[j] if s not in sequence: if s in sums: sums[s] += 1 else: sums[s] = 1 min_sum = min(s for s, count in sums.items() if count == 1) sequence.append(min_sum) return sequence def calculate_sum(n, k): total_sum = 0 for i in range(2, n+1): ulam_seq = ulam_sequence(2, 2*i+1, k) ulam_sum = sum(ulam_seq) total_sum += ulam_sum return total_sum # Calculate the sum for n=10 and k=10^11 n = 10 k = 10**11 result = calculate_sum(n, k) print(result) ``` This code defines two functions: `ulam_sequence()` and `calculate_sum()`. The `ulam_sequence()` function generates the Ulam sequence up to the `k`th term for a given `a` and `b`. It uses a nested loop to iterate over all possible pairs of distinct previous numbers and calculates their sum. It keeps track of the number of times each sum occurs and selects the smallest sum that is unique. This process continues until the sequence reaches the `k`th term. The `calculate_sum()` function calculates the required sum by iterating over the range from 2 to `n`, inclusive. For each `i`, it calls the `ulam_sequence()` function with `a=2` and `b=2*i+1`, and sums the generated Ulam sequence. The total sum is accumulated and returned. Finally, the main part of the code sets `n` to 10 and `k` to `10^11`. It calls the `calculate_sum()` function with these values and prints the result. Note: The code may take some time to run since the value of `k` is very large.

More Answers:
Three Consecutive Digital Sum Limit
Criss Cross

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!