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

Characterization of Carmichael numbers via squarefree denominators $a(n)$

$a(n)$ is the denominator of $F(n) = \operatorname{num}(B_{n-1})/n + \operatorname{den}(B_{n-1})/n^2$.

A composite number $n$ has squarefree $a(n)$ if and only if $n$ is a Carmichael number.

References:

namespace OeisA309132open Rat Nat

$a(n)$ is the denominator of $F(n)$ = A027641(n-1)/n + A027642(n-1)/n^2.

def a (n : ) : := if n = 0 then 0 else let n_q : := n let B_nm1 : := bernoulli (n - 1) let F_n : := (B_nm1.num : ) / n_q + (B_nm1.den : ) / (n_q * n_q) F_n.den

Definition of a Carmichael number $n$: a composite number s.t. $b^{n-1} \equiv 1 \pmod n$ for all $b$ coprime to $n$.

def IsCarmichaelNumber (n : ) : Prop := (¬ Nat.Prime n n > 1) ( b : , Nat.gcd b n = 1 b ^ (n - 1) 1 [MOD n])

Helper definition for "composite number"

def IsComposite (n : ) : Prop := ¬ Nat.Prime n n > 1@[category test, AMS 11] lemma a_1 : a 1 = 1 := a 1 = 1 (if 1 = 0 then 0 else have n_q := 1; have B_nm1 := bernoulli (1 - 1); have F_n := B_nm1.num / n_q + B_nm1.den / (n_q * n_q); F_n.den) = 1; All goals completed! 🐙@[category test, AMS 11] lemma a_2 : a 2 = 1 := a 2 = 1 (if 2 = 0 then 0 else have n_q := 2; have B_nm1 := bernoulli (2 - 1); have F_n := B_nm1.num / n_q + B_nm1.den / (n_q * n_q); F_n.den) = 1; All goals completed! 🐙@[category test, AMS 11] lemma a_3 : a 3 = 1 := a 3 = 1 (if 3 = 0 then 0 else have n_q := 3; have B_nm1 := bernoulli (3 - 1); have F_n := B_nm1.num / n_q + B_nm1.den / (n_q * n_q); F_n.den) = 1; All goals completed! 🐙@[category test, AMS 11] lemma a_4 : a 4 = 16 := a 4 = 16 (if 4 = 0 then 0 else have n_q := 4; have B_nm1 := bernoulli (4 - 1); have F_n := B_nm1.num / n_q + B_nm1.den / (n_q * n_q); F_n.den) = 16; All goals completed! 🐙@[category test, AMS 11] lemma a_5 : a 5 = 1 := a 5 = 1 (if 5 = 0 then 0 else have n_q := 5; have B_nm1 := bernoulli (5 - 1); have F_n := B_nm1.num / n_q + B_nm1.den / (n_q * n_q); F_n.den) = 1; All goals completed! 🐙

Conjecture: composite numbers $n$ such that $a(n)$ is squarefree are only the Carmichael numbers (A002997). - Thomas Ordowski, Jul 15 2019

A formal proof has been found with the methods described in arxiv/2605.22763.

@[category research solved, AMS 11, formal_proof using formal_conjectures at "https://github.com/mo271/formal-conjectures/blob/a32396489dcb8f86c3549b93aa358ac6a10a3a1f/FormalConjectures/OEIS/309132.wip.lean#L353"] theorem carmichael_iff_squarefree_a : (n : ), (IsComposite n Squarefree (a n)) IsCarmichaelNumber n := (n : ), IsComposite n Squarefree (a n) IsCarmichaelNumber n All goals completed! 🐙end OeisA309132