/- 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 FormalConjecturesUtil

Least $m$ such that $m + n$ divides $\mathrm{prime}(m) + \mathrm{prime}(n)$

The sequence $a(n)$ is the least positive integer $m$ such that $m + n$ divides $\mathrm{prime}(m) + \mathrm{prime}(n)$, where $\mathrm{prime}(k)$ denotes the $k$-th prime number (with $\mathrm{prime}(1) = 2$).

References:

@[expose] public sectionnamespace OeisA247824open Nat Set

Least positive integer $m$ such that $m + n$ divides $\mathrm{prime}(m) + \mathrm{prime}(n)$. If no such $m$ exists (or if $n = 0$), returns $0$.

noncomputable def a (n : ℕ) : ℕ := if n = 0 then 0 else sInf { m : ℕ | 0 < m ∧ (m + n) ∣ (Nat.nth Nat.Prime (m - 1) + Nat.nth Nat.Prime (n - 1)) }h:nth Nat.Prime 0 + nth Nat.Prime 0 = 2 * nth Nat.Prime 0⊢ 1 + 1 ∣ 2 * nth Nat.Prime 0 All goals completed! 🐙@[category test, AMS 11] theorem a_2 : a 2 = 5 := ⊢ a 2 = 5 ⊢ sInf {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} = 5 ⊢ IsLeast {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} 5 refine ⟨⟨⊢ 0 < 5 All goals completed! 🐙, ?_⟩, fun m hm => ?_⟩ ⊢ 5 + 2 ∣ nth Nat.Prime (5 - 1) + nth Nat.Prime 1 All goals completed! 🐙 m:ℕhm:m ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}⊢ 5 ≤ m m:ℕhm:m ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:m < 5⊢ False m:ℕhm:m ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:m < 5hm1:0 < m⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:1 < 5hm1:0 < 1⊢ Falsem:ℕhm:2 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:2 < 5hm1:0 < 2⊢ Falsem:ℕhm:3 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:3 < 5hm1:0 < 3⊢ Falsem:ℕhm:4 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:1 < 5hm1:0 < 1⊢ False m:ℕhlt:1 < 5hm1:0 < 1⊢ 1 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} → False; All goals completed! 🐙 m:ℕhm:2 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:2 < 5hm1:0 < 2⊢ False m:ℕhlt:2 < 5hm1:0 < 2⊢ 2 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} → False; All goals completed! 🐙 m:ℕhm:3 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:3 < 5hm1:0 < 3⊢ False m:ℕhlt:3 < 5hm1:0 < 3⊢ 3 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} → False; All goals completed! 🐙 m:ℕhm:4 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhlt:4 < 5hm1:0 < 4⊢ 4 ∈ {m | 0 < m ∧ m + 2 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 1} → False; All goals completed! 🐙@[category test, AMS 11] theorem a_3 : a 3 = 5 := ⊢ a 3 = 5 ⊢ sInf {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} = 5 ⊢ IsLeast {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} 5 refine ⟨⟨⊢ 0 < 5 All goals completed! 🐙, ?_⟩, fun m hm => ?_⟩ ⊢ 5 + 3 ∣ nth Nat.Prime (5 - 1) + nth Nat.Prime 2 All goals completed! 🐙 m:ℕhm:m ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}⊢ 5 ≤ m m:ℕhm:m ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:m < 5⊢ False m:ℕhm:m ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:m < 5hm1:0 < m⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:1 < 5hm1:0 < 1⊢ Falsem:ℕhm:2 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:2 < 5hm1:0 < 2⊢ Falsem:ℕhm:3 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:3 < 5hm1:0 < 3⊢ Falsem:ℕhm:4 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:1 < 5hm1:0 < 1⊢ False m:ℕhlt:1 < 5hm1:0 < 1⊢ 1 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} → False; All goals completed! 🐙 m:ℕhm:2 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:2 < 5hm1:0 < 2⊢ False m:ℕhlt:2 < 5hm1:0 < 2⊢ 2 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} → False; All goals completed! 🐙 m:ℕhm:3 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:3 < 5hm1:0 < 3⊢ False m:ℕhlt:3 < 5hm1:0 < 3⊢ 3 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} → False; All goals completed! 🐙 m:ℕhm:4 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhlt:4 < 5hm1:0 < 4⊢ 4 ∈ {m | 0 < m ∧ m + 3 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 2} → False; All goals completed! 🐙@[category test, AMS 11] theorem a_4 : a 4 = 5 := ⊢ a 4 = 5 ⊢ sInf {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} = 5 ⊢ IsLeast {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} 5 refine ⟨⟨⊢ 0 < 5 All goals completed! 🐙, ?_⟩, fun m hm => ?_⟩ ⊢ 5 + 4 ∣ nth Nat.Prime (5 - 1) + nth Nat.Prime 3 All goals completed! 🐙 m:ℕhm:m ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}⊢ 5 ≤ m m:ℕhm:m ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:m < 5⊢ False m:ℕhm:m ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:m < 5hm1:0 < m⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:1 < 5hm1:0 < 1⊢ Falsem:ℕhm:2 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:2 < 5hm1:0 < 2⊢ Falsem:ℕhm:3 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:3 < 5hm1:0 < 3⊢ Falsem:ℕhm:4 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:1 < 5hm1:0 < 1⊢ False m:ℕhlt:1 < 5hm1:0 < 1⊢ 1 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} → False; All goals completed! 🐙 m:ℕhm:2 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:2 < 5hm1:0 < 2⊢ False m:ℕhlt:2 < 5hm1:0 < 2⊢ 2 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} → False; All goals completed! 🐙 m:ℕhm:3 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:3 < 5hm1:0 < 3⊢ False m:ℕhlt:3 < 5hm1:0 < 3⊢ 3 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} → False; All goals completed! 🐙 m:ℕhm:4 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3}hlt:4 < 5hm1:0 < 4⊢ False m:ℕhlt:4 < 5hm1:0 < 4⊢ 4 ∈ {m | 0 < m ∧ m + 4 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 3} → False; All goals completed! 🐙@[category test, AMS 11] theorem a_5 : a 5 = 2 := ⊢ a 5 = 2 ⊢ sInf {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4} = 2 ⊢ IsLeast {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4} 2 refine ⟨⟨⊢ 0 < 2 All goals completed! 🐙, ?_⟩, fun m hm => ?_⟩ ⊢ 2 + 5 ∣ nth Nat.Prime (2 - 1) + nth Nat.Prime 4 All goals completed! 🐙 m:ℕhm:m ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4}⊢ 2 ≤ m m:ℕhm:m ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4}hlt:m < 2⊢ False m:ℕhm:m ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4}hlt:m < 2hm1:0 < m⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4}hlt:1 < 2hm1:0 < 1⊢ False m:ℕhm:1 ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4}hlt:1 < 2hm1:0 < 1⊢ False m:ℕhlt:1 < 2hm1:0 < 1⊢ 1 ∈ {m | 0 < m ∧ m + 5 ∣ nth Nat.Prime (m - 1) + nth Nat.Prime 4} → False; All goals completed! 🐙

Conjecture: $a(n)$ exists for any $n > 0$. The existence of $a(n)$ for $n > 0$ is formalized by requiring that the defining set is nonempty (equivalently, $0 < a(n)$).

    Zhi-Wei Sun, Sep 25 2014

@[category research open, AMS 11] theorem conjecture_1 (n : ℕ) (hn : 0 < n) : ({ m : ℕ | 0 < m ∧ (m + n) ∣ (Nat.nth Nat.Prime (m - 1) + Nat.nth Nat.Prime (n - 1)) }).Nonempty := n:ℕhn:0 < n⊢ {m | 0 < m ∧ m + n ∣ nth Nat.Prime (m - 1) + nth Nat.Prime (n - 1)}.Nonempty All goals completed! 🐙

Conjecture: $a(n) < n(n-1)$ for all $n > 2$.

    Zhi-Wei Sun, Sep 25 2014

Disproved by Khai-Hoan Nguyen-Dang (Oct 30 2026), who found the counterexample $n = 1322164$, for which $a(1322164) = 2636932401176 > 1748116320732 = 1322164 \cdot 1322163$.

@[category research solved, AMS 11] theorem conjecture_2 : ¬ ∀ n : ℕ, 2 < n → a n < n * (n - 1) := ⊢ ¬∀ (n : ℕ), 2 < n → OeisA247824.a n < n * (n - 1) All goals completed! 🐙end OeisA247824