Powers of $1 + \sqrt{7}$
Define alpha(n) and beta(n) by (1 + sqrt(7))^n = alpha(n) + beta(n)sqrt(7). Let g(x) be the smallest positive integer n such that alpha(n) equiv 1 (mod x) and beta(n) equiv 0 (mod x). Define G(N) =...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
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 \[\displaystyle G(N) = \sum _{x=2}^N g(x)\] You are given \(G(10^2) = 28891\) and \(G(10^3) = 13131583\).
Find \(G(10^6)\).
Problem 752: Powers of
Mathematical Foundation
Lemma 1 (Matrix recurrence). The pair satisfies
Proof. By induction. The base case gives . For the inductive step, , which matches multiplication by .
Theorem 1 (Order characterization). is the multiplicative order of in with respect to the identity, i.e., .
Proof. The condition means . Since , and generates a subgroup of , examining the full matrix power shows is equivalent to the stated condition (verifiable by checking both columns).
Lemma 2 (Pisano-type period for primes). For a prime :
- If : compute directly.
- If : the characteristic polynomial ; compute directly.
- If (i.e., is a quadratic residue mod ): then .
- If : then but . In all cases, .
Proof. The eigenvalues of over are . When is a QR mod , and the eigenvalues lie in , so . When is a QNR, the eigenvalues lie in , and the Frobenius endomorphism gives (since the eigenvalues satisfy and , but the order divides ). In either case , and finding amounts to finding the exact order by testing divisors.
Lemma 3 (Multiplicativity for prime powers and composites).
- For a prime power : can be computed by lifting from using Hensel-type arguments. Typically for odd, with exceptions when the period stabilizes.
- For composite : .
Proof. The lcm formula follows from the Chinese Remainder Theorem: iff for all . The prime power lifting is standard (analogous to the Pisano period for Fibonacci numbers).
Editorial
. = smallest with . . Given . Find $G(. We compute g(p) for each prime p <= N. We then iterate over each prime p in primes. Finally, else.
Pseudocode
Compute g(p) for each prime p <= N
for each prime p in primes
else
Find order of M mod p by testing divisors of bound
for d in divisors
Compute g(p^k) for prime powers p^k <= N
for each prime p
Lift: typically g(p^k) = p * g(p^{k-1}), verify by checking
Compute g(x) for composite x via lcm
Use a sieve-like approach: for each x, factorize and take lcm
Complexity Analysis
- Time: dominated by the sieve and factorization steps. Computing for each prime requires testing divisors where is the divisor function, with matrix exponentiation in per test.
- Space: for the sieve and the array of -values.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
/*
* Problem 752: Powers of 1+sqrt(7)
*
* $(1+\sqrt{7})^n = \alpha(n)+\beta(n)\sqrt{7}$. $g(x)$ = smallest $n>0$ with $\alpha(n)\equiv 1, \beta(n)\equiv 0 \pmod x$. $G(N)=\sum_{{x=2}}^N g(x)$.
*/
int main() {
printf("Problem 752: Powers of 1+sqrt(7)\n");
return 0;
}
"""
Problem 752: Powers of 1+sqrt(7)
$(1+\sqrt{7})^n = \alpha(n)+\beta(n)\sqrt{7}$. $g(x)$ = smallest $n>0$ with $\alpha(n)\equiv 1, \beta(n)\equiv 0 \pmod x$. $G(N)=\sum_{{x=2}}^N g(x)$. Given $G(10^2)=28891, G(10^3)=13131583$. Find $G(
"""
print("Problem 752: Powers of 1+sqrt(7)")
# See solution.md for mathematical analysis