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

Smallest 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 in

Smallest $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.

h: k, List.count 6 (Nat.digits 10 k.factorial) = 1List.count 6 (Nat.digits 10 (Nat.factorial 3)) = 1 n < 3, ¬List.count 6 (Nat.digits 10 n.factorial) = 1 All goals completed! 🐙 h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 1False exact (h 3, h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 1List.count 6 (Nat.digits 10 (Nat.factorial 3)) = 1 All goals completed! 🐙).elim

Value of the sequence a at 2.

h: k, List.count 6 (Nat.digits 10 k.factorial) = 2List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 n < 15, ¬List.count 6 (Nat.digits 10 n.factorial) = 2 All goals completed! 🐙 h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 2False exact (h 15, h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 2List.count 6 (Nat.digits 10 (Nat.factorial 15)) = 2 All goals completed! 🐙).elim

Value of the sequence a at 3.

h: k, List.count 6 (Nat.digits 10 k.factorial) = 3List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 n < 23, ¬List.count 6 (Nat.digits 10 n.factorial) = 3 All goals completed! 🐙 h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 3False exact (h 23, h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 3List.count 6 (Nat.digits 10 (Nat.factorial 23)) = 3 All goals completed! 🐙).elim

Value of the sequence a at 4.

h: k, List.count 6 (Nat.digits 10 k.factorial) = 4List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 n < 26, ¬List.count 6 (Nat.digits 10 n.factorial) = 4 All goals completed! 🐙 h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 4False exact (h 26, h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 4List.count 6 (Nat.digits 10 (Nat.factorial 26)) = 4 All goals completed! 🐙).elim

Value of the sequence a at 5.

h: k, List.count 6 (Nat.digits 10 k.factorial) = 5List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 n < 32, ¬List.count 6 (Nat.digits 10 n.factorial) = 5 All goals completed! 🐙 h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 5False exact (h 32, h:¬ k, List.count 6 (Nat.digits 10 k.factorial) = 5List.count 6 (Nat.digits 10 (Nat.factorial 32)) = 5 All goals completed! 🐙).elim

It 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 := a 24 = 0 All goals completed! 🐙end OeisA72200