/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import FormalConjecturesUtilRatio of product of GCDs to product of factorials of floor divisions
$$a(n) = \frac{\prod_{j=1}^n \prod_{k=1}^n \gcd(j,k)}{\prod_{k=1}^n (\lfloor n/k \rfloor!)^k}$$
References:
@[expose] public sectionnamespace OeisA129365$a(n) = \frac{\prod_{j=1}^n \prod_{k=1}^n \gcd(j,k)}{\prod_{k=1}^n (\lfloor n/k \rfloor!)^k}$.
def a (n : ℕ) : ℚ :=
let num : ℚ := (Finset.Icc 1 n).prod fun j => (Finset.Icc 1 n).prod fun k => Nat.gcd j k
let den : ℚ := (Finset.Icc 1 n).prod fun k => (n / k).factorial ^ k
num / denSequence A004125: sum of remainders $n \bmod k$ for $1 \le k \le n$.
def b (n : ℕ) : ℕ :=
∑ k ∈ Finset.Icc 1 n, (n % k)
Value of the sequence a at 0.
@[category test, AMS 11]
theorem a_0 : a 0 = 1 := ⊢ a 0 = 1 All goals completed! 🐙
Value of the sequence a at 1.
@[category test, AMS 11]
theorem a_1 : a 1 = 1 := ⊢ a 1 = 1 All goals completed! 🐙
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 1 := ⊢ a 2 = 1 All goals completed! 🐙
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 1 := ⊢ a 3 = 1 All goals completed! 🐙
Value of the sequence a at 4.
@[category test, AMS 11]
theorem a_4 : a 4 = 1 := ⊢ a 4 = 1 All goals completed! 🐙Conjecture (1): $a(n)$ is always an integer (the denominator divides the numerator).
Proof summary:
Let $c(n) = \prod_{j=1}^n \prod_{k=1}^n (j,k)$ be the numerator. Observe that $$\textrm{ord}(c(n), p) = \left\lfloor \frac{n}{p} \right\rfloor^2 + \left\lfloor \frac{n}{p^2} \right\rfloor^2 + ...$$ proven similar to Legendre's formula for $\textrm{ord}(n!, p)$.
Next let $d(n) = \prod_{k=1}^n (\lfloor n/k \rfloor!)^k$ be the denominator. Observe that $$\textrm{ord}(d(n), p) = \sum_{k=1}^n k,\textrm{ord}(\lfloor n/k \rfloor, p) = \sum_{k=1}^n \sum_{r \geq 1} k \left\lfloor \frac{\lfloor n/p^r \rfloor}{k} \right\rfloor.$$
Combining the two gives: $$\textrm{ord}(a(n), p) = \sum_{r \geq 1} \sum_{k=1}^n \left(\left\lfloor \frac{n}{p^r} \right\rfloor \textrm{mod } k\right).$$
Defining $b(m) = \sum_{k=1}^m m \textrm{ mod } k$, we obtain $\textrm{ord}(a(n), p) = \sum_{r \geq 1} b(\lfloor n/p^r \rfloor)$.
As $b(m) \geq 0$, $\textrm{ord}(a(n), p)$ is non-negative for any $p$, so $a(n)$ is an integer.
@[category research solved, AMS 11,
formal_proof using lean4 at
"https://github.com/KitaKen1/oeis-a129365-conjectures/blob/9c0201540c337733d6b8afb2aff209f5489c122a/lean/OeisA129365FC.lean#L234-L395"]
theorem conjecture1 (n : ℕ) (hn : 0 < n) :
((Finset.Icc 1 n).prod fun k => (n / k).factorial ^ k) ∣
((Finset.Icc 1 n).prod fun j => (Finset.Icc 1 n).prod fun k => Nat.gcd j k) := n:ℕhn:0 < n⊢ ∏ k ∈ Finset.Icc 1 n, (n / k).factorial ^ k ∣ ∏ j ∈ Finset.Icc 1 n, ∏ k ∈ Finset.Icc 1 n, j.gcd k
All goals completed! 🐙Conjecture (2): If $p$ is a prime, then $p \mid a(n)$ if and only if $p \le n/3$.
Proof summary:
We use the formula shown above: $\textrm{ord}(a(n), p) = \sum_{r \geq 1} b(\lfloor n/p^r \rfloor)$ where $b(m) = \sum_{k=1}^m m \textrm{ mod } k$.
If $p ∣ a(n)$ then $b(\lfloor n/p^r \rfloor) ≥ 1$ for some $r ≥ 1$. Since b(m) = 0$ for $m \leq 2$, we must have $n / p^r \geq 3$. If the inequality holds for $r \geq 1$, it must be true for $r = 1$. Hence $n \geq 3p$, proving the conjecture.
@[category research solved, AMS 11,
formal_proof using lean4 at
"https://github.com/KitaKen1/oeis-a129365-conjectures/blob/9c0201540c337733d6b8afb2aff209f5489c122a/lean/OeisA129365FC.lean#L234-L395"]
theorem conjecture2 (n p : ℕ) (hn : 0 < n) (hp : p.Prime) :
(∃ m : ℕ, a n = m ∧ p ∣ m) ↔ p ≤ n / 3 := n:ℕp:ℕhn:0 < nhp:Nat.Prime p⊢ (∃ m, a n = ↑m ∧ p ∣ m) ↔ p ≤ n / 3
All goals completed! 🐙Conjecture (3): For each positive integer $n$, prime $p$, and $0 \le k < p$, $\mathrm{ord}_p(a(np)) = \mathrm{ord}_p(a(np + k))$.
Proof summary:
This follows from the formula shown above: $\textrm{ord}(a(n), p) = \sum_{r \geq 1} b(\lfloor n/p^r \rfloor)$ where $b(m) = \sum_{k=1}^m m \textrm{ mod } k$.
Since $k < p$, we have $\lfloor (np + k)/p^r \rfloor = \lfloor np/p^r \rfloor$ for every $r \geq 1$, proving the claim.
@[category research solved, AMS 11,
formal_proof using lean4 at
"https://github.com/KitaKen1/oeis-a129365-conjectures/blob/9c0201540c337733d6b8afb2aff209f5489c122a/lean/OeisA129365FC.lean#L234-L395"]
theorem conjecture3 (n p k : ℕ) (hn : 0 < n) (hp : p.Prime) (hk : k < p) :
padicValRat p (a (n * p)) = padicValRat p (a (n * p + k)) := n:ℕp:ℕk:ℕhn:0 < nhp:Nat.Prime phk:k < p⊢ padicValRat p (a (n * p)) = padicValRat p (a (n * p + k))
All goals completed! 🐙Conjecture (4): Let $b(n) = \mathrm{A004125}(n) = \sum_{k=1}^n (n \bmod k)$. Then $\mathrm{ord}p(a(np)) = \sum{i \ge 0} b(\lfloor n/p^i \rfloor)$.
Proof summary:
This follows directly from the formula shown at the beginning: $\textrm{ord}(a(n), p) = \sum_{r \geq 1} b(\lfloor n/p^r \rfloor)$ where $b(m) = \sum_{k=1}^m m \textrm{ mod } k$.
@[category research solved, AMS 11,
formal_proof using lean4 at
"https://github.com/KitaKen1/oeis-a129365-conjectures/blob/9c0201540c337733d6b8afb2aff209f5489c122a/lean/OeisA129365FC.lean#L234-L395"]
theorem conjecture4 (n p : ℕ) (hn : 0 < n) (hp : p.Prime) :
padicValRat p (a (n * p)) = ∑' i : ℕ, (b (n / p ^ i) : ℤ) := n:ℕp:ℕhn:0 < nhp:Nat.Prime p⊢ padicValRat p (a (n * p)) = ∑' (i : ℕ), ↑(b (n / p ^ i))
All goals completed! 🐙end OeisA129365