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

Decimal Repunit Primes

A decimal repunit is a natural number whose decimal representation consists entirely of ones. It is conjectured that infinitely many decimal repunits are prime.

References:

@[expose] public sectionnamespace RepunitPrime

The decimal repunit of length $n$, defined as $1 + 10 + \cdots + 10^{n-1}$.

def repunit10 (n : ℕ) : ℕ := ∑ i ∈ Finset.range n, 10 ^ i@[category test, AMS 11] theorem repunit10_one : repunit10 1 = 1 := ⊢ repunit10 1 = 1 All goals completed! 🐙@[category test, AMS 11] theorem repunit10_two : repunit10 2 = 11 := ⊢ repunit10 2 = 11 All goals completed! 🐙@[category test, AMS 11] theorem repunit10_three : repunit10 3 = 111 := ⊢ repunit10 3 = 111 All goals completed! 🐙@[category test, AMS 11] theorem repunit10_four : repunit10 4 = 1111 := ⊢ repunit10 4 = 1111 All goals completed! 🐙@[category test, AMS 11] theorem repunit10_five : repunit10 5 = 11111 := ⊢ repunit10 5 = 11111 All goals completed! 🐙@[category test, AMS 11] theorem repunit10_two_prime : (repunit10 2).Prime := ⊢ Nat.Prime (repunit10 2) All goals completed! 🐙@[category test, AMS 11] theorem repunit10_three_not_prime : ¬ (repunit10 3).Prime := ⊢ ¬Nat.Prime (repunit10 3) ⊢ ∃ x < 111, x ∣ 111 ∧ ¬x = 1 exact ⟨3, ⊢ 3 < 111 All goals completed! 🐙, ⊢ 3 ∣ 111 All goals completed! 🐙, ⊢ ¬3 = 1 All goals completed! 🐙⟩

Wikipedia's repunit article states: "It has been conjectured that there are infinitely many repunit primes."

@[category research open, AMS 11] theorem infinitely_many_repunit_primes : {n : ℕ | (repunit10 n).Prime}.Infinite := ⊢ {n | Nat.Prime (repunit10 n)}.Infinite All goals completed! 🐙end RepunitPrime