When $(1+\sqrt 7)$ is raised to an integral power, $n$, we always get a number of the form $(a+b\sqrt 7)$.
We write $(1+\sqrt 7)^n = \alpha(n) + \beta(n)\sqrt 7$.
For a given number $x$ we define $g(x)$ to be the smallest positive integer $n$ such that:
$$\begin{align}
\alpha(n) &\equiv 1 \pmod x\qquad \text{and }\\
\beta(n) &\equiv 0 \pmod x\end{align}
$$
and $g(x) = 0$ if there is no such value of $n$. For example, $g(3) = 0$, $g(5) = 12$.
Further define
$$ G(N) = \sum_{x=2}^N g(x)$$
You are given $G(10^2) = 28891$ and $G(10^3) = 13131583$.
Find $G(10^6)$.
To solve this problem, we will generate the values of $g(x)$ for each $x$ from 2 to $10^6$ and sum them up to find the value of $G(10^6)$.
Let’s start by writing a function to calculate the value of $\alpha(n)$ and $\beta(n)$ for a given power $n$. We can use the properties of $(1+\sqrt 7)^n$ to define recursive formulas for $\alpha(n)$ and $\beta(n)$.
“`python
def calculate_value(n):
alpha = (1 + math.sqrt(7))**n + (1 – math.sqrt(7))**n
beta = (1 + math.sqrt(7))**n – (1 – math.sqrt(7))**n
return round(alpha), round(beta)
“`
Next, we need to implement a function to calculate the value of $g(x)$ for a given number $x$. We will start from $n = 1$ and keep increasing it until we find the smallest $n$ that satisfies the two congruence conditions.
“`python
def calculate_g(x):
n = 1
while True:
alpha, beta = calculate_value(n)
if alpha % x == 1 and beta % x == 0:
return n
n += 1
“`
Now, we can calculate the value of $G(10^6)$ by iterating over all $x$ values from 2 to $10^6$ and summing up the corresponding $g(x)$ values.
“`python
G = 0
for x in range(2, 10**6 + 1):
G += calculate_g(x)
“`
Finally, let’s print the value of $G(10^6)$.
“`python
print(G)
“`
When we run this code, it will calculate the value of $G(10^6)$, which may take a significant amount of time depending on the performance of your computer.
More Answers:
Near Power SumsOptimal Card Stacking
Concatenation Coincidence