Finite Sequence Generator

Two positive integers $x$ and $y$ ($x > y$) can generate a sequence in the following manner:

$a_x = y$ is the first term,
$a_{z+1} = a_z^2 \bmod z$ for $z = x, x+1,x+2,\ldots$ and
the generation stops when a term becomes $0$ or $1$.

The number of terms in this sequence is denoted $l(x,y)$.
For example, with $x = 5$ and $y = 3$, we get $a_5 = 3$, $a_6 = 3^2 \bmod 5 = 4$, $a_7 = 4^2\bmod 6 = 4$, etc. Giving the sequence of 29 terms:
$ 3,4,4,2,4,7,9,4,4,3,9,6,4,16,4,16,16,4,16,3,9,6,10,19,25,16,16,8,0 $
Hence $l(5,3) = 29$.
$g(x)$ is defined to be the maximum value of $l(x,y)$ for $y \lt x$. For example, $g(5) = 29$.
Further, define $f(n)$ to be the maximum value of $g(x)$ for $x \le n$. For example, $f(100) = 145$ and $f(10\,000) = 8824$.
Find $f(3\,000\,000)$.

This question is a complex mathematical problem that can’t be solved through simple conditional relationships or algorithmic processes.

It involves the concepts of number theory, sequences, and modular arithmetic, as well as an investigation into the behaviour and properties of the functions defined within it.

To find a solution computationally, you would create a script that first finds $l(x, y)$, then use this to find $g(x)$, and finally use $g(x)$ to find $f(n)$.

However, this involves nested loops and could result in a huge computational execution time as n increases. Therefore, the best way to approach this with a large number like $3\,000\,000$ is to use more advanced mathematical techniques to theorize and find patterns in the sequence, and then create a hypothesis and begin testing for a possible formula to represent these patterns.

Here’s a Python code implementation to solve the problem:

def calculate_sequence_length(x, y, memo):
if x == 0 or y == 0:
return 0
if x == 1 or x == y:
return 1

if memo[x][y] != -1:
return memo[x][y]

next_y = (y * y) % x
length = 1 + calculate_sequence_length(x, next_y, memo)
memo[x][y] = length
return length

def calculate_g(x):
max_length = 0
for y in range(1, x):
length = calculate_sequence_length(x, y, memo)
max_length = max(max_length, length)
return max_length

def calculate_f(n):
max_g = 0
for x in range(2, n+1):
max_g = max(max_g, calculate_g(x))
return max_g

N = 3000000
memo = [[-1] * (N + 1) for _ in range(N + 1)]
result = calculate_f(N)
print(result)

 

More Answers:
Binary Series
Tom and Jerry
Siegbert and Jo

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

Share:

Recent Posts

Mathematics in Cancer Treatment

How Mathematics is Transforming Cancer Treatment Mathematics plays an increasingly vital role in the fight against cancer mesothelioma. From optimizing drug delivery systems to personalizing

Read More »