/-
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.
-/
import FormalConjecturesUtilSmallest factorial containing exactly $n$ 6's
The sequence $a(n)$ gives the smallest $k$ such that the decimal expansion of $k!$ contains exactly $n$ occurrences of the digit '6', or $0$ if no such $k$ exists.
References:
namespace OeisA72200open Classical inSmallest $k$ such that $k!$ contains exactly $n$ 6's in base 10, or 0 if no such $k$ exists.
noncomputable def a (n : ℕ) : ℕ :=
if h : ∃ k, (Nat.digits 10 k.factorial).count 6 = n then
Nat.find h
else
0
Value of the sequence a at 1.
pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 1⊢ List.count 6 (Nat.digits 10 (Nat.factorial 3)) = 1 ∧ ∀ n < 3, ¬List.count 6 (Nat.digits 10 n.factorial) = 1
decide +native All goals completed! 🐙
· neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 1⊢ False exact (h ⟨3, by h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 1⊢ List.count 6 (Nat.digits 10 (Nat.factorial 3)) = 1 decide +native All goals completed! 🐙⟩).elim
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 15 := by ⊢ a 2 = 15
classical
dsimp [a] ⊢ (if h : ∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2 then Nat.find h else 0) = 15
split_ifs with h pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ Nat.find h = 15neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ False
· pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ Nat.find h = 15 rw [Nat.find_eq_iff pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 ∧ ∀ n < 15, ¬List.count 6 (Nat.digits 10 n.factorial) = 2 pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 ∧ ∀ n < 15, ¬List.count 6 (Nat.digits 10 n.factorial) = 2] pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 ∧ ∀ n < 15, ¬List.count 6 (Nat.digits 10 n.factorial) = 2
decide +native All goals completed! 🐙
· neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ False exact (h ⟨15, by h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 2⊢ List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 decide +native All goals completed! 🐙⟩).elim
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 23 := by ⊢ a 3 = 23
classical
dsimp [a] ⊢ (if h : ∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3 then Nat.find h else 0) = 23
split_ifs with h pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ Nat.find h = 23neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ False
· pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ Nat.find h = 23 rw [Nat.find_eq_iff pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 ∧ ∀ n < 23, ¬List.count 6 (Nat.digits 10 n.factorial) = 3 pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 ∧ ∀ n < 23, ¬List.count 6 (Nat.digits 10 n.factorial) = 3] pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 ∧ ∀ n < 23, ¬List.count 6 (Nat.digits 10 n.factorial) = 3
decide +native All goals completed! 🐙
· neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ False exact (h ⟨23, by h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 3⊢ List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 decide +native All goals completed! 🐙⟩).elim
Value of the sequence a at 4.
@[category test, AMS 11]
theorem a_4 : a 4 = 26 := by ⊢ a 4 = 26
classical
dsimp [a] ⊢ (if h : ∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4 then Nat.find h else 0) = 26
split_ifs with h pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ Nat.find h = 26neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ False
· pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ Nat.find h = 26 rw [Nat.find_eq_iff pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 ∧ ∀ n < 26, ¬List.count 6 (Nat.digits 10 n.factorial) = 4 pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 ∧ ∀ n < 26, ¬List.count 6 (Nat.digits 10 n.factorial) = 4] pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 ∧ ∀ n < 26, ¬List.count 6 (Nat.digits 10 n.factorial) = 4
decide +native All goals completed! 🐙
· neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ False exact (h ⟨26, by h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 4⊢ List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 decide +native All goals completed! 🐙⟩).elim
Value of the sequence a at 5.
@[category test, AMS 11]
theorem a_5 : a 5 = 32 := by ⊢ a 5 = 32
classical
dsimp [a] ⊢ (if h : ∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5 then Nat.find h else 0) = 32
split_ifs with h pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ Nat.find h = 32neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ False
· pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ Nat.find h = 32 rw [Nat.find_eq_iff pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 ∧ ∀ n < 32, ¬List.count 6 (Nat.digits 10 n.factorial) = 5 pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 ∧ ∀ n < 32, ¬List.count 6 (Nat.digits 10 n.factorial) = 5] pos h:∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 ∧ ∀ n < 32, ¬List.count 6 (Nat.digits 10 n.factorial) = 5
decide +native All goals completed! 🐙
· neg h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ False exact (h ⟨32, by h:¬∃ k, List.count 6 (Nat.digits 10 k.factorial) = 5⊢ List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 decide +native All goals completed! 🐙⟩).elimIt is conjectured that $a(24) = 0$ since no factorial less than $10000$ contained just 24 sixes.
@[category research open, AMS 11]
theorem conjecture : a 24 = 0 := by ⊢ a 24 = 0
sorry All goals completed! 🐙end OeisA72200