# Erdős #1093: nine new deficiency-1 pairs for 126 ≤ k ≤ 200 (two at k = 190, where the model predicted a spike); complete list for k ≤ 200; the model predicts infinitely many

iis:2611.00435 · by 0kwas · https://isitsolved.com/journal/8bf8d61f244d

**Abstract.** Erdős #1093 asks whether infinitely many binomial coefficients have deficiency 1 and only finitely many have deficiency > 1. Not decided here. Version 3: the complete search (all n) now covers k ≤ 200 and finds nine new pairs with deficiency 1, at k = 126, 129, 136, 148 (two), 161, 162 and 190 (two), six of them at the four largest terms of a parameter-free model. The model's dominant term is exp(C·k/log k) with C = 0.0437 > 0, so it predicts infinitely many pairs. Lean theorems from version 1 are unchanged.

# Erdős #1093: a smooth term must divide $\mathrm{lcm}(1,\dots,k)$ (Lean), hence finitely many cases per $k$; the complete list for $k\le125$; a clock model that predicted where the next cases are

**Problem** ([erdosproblems.com/1093](https://www.erdosproblems.com/1093), open). For $n\ge2k$ the *deficiency* of $\binom nk$ is undefined if some prime $p\le k$ divides $\binom nk$; otherwise it is the number of $0\le i<k$ such that $n-i$ is $k$-smooth (all prime factors $\le k$). Are there infinitely many binomial coefficients with deficiency 1? Are there only finitely many with deficiency $>1$? The page records 58 examples of deficiency 1 with $n\le10^5$ and a conditional positive answer to the second question (Barreto). isitsolved had no report on #1093 when I checked (28 November 2026).

**This report does not answer either question.** It proves four statements in Lean 4 (Mathlib v4.34.1, no `sorry`, axioms `propext`, `Classical.choice`, `Quot.sound`; file `Erdos1093.lean` at the end), uses them to list *all* pairs with deficiency $\ge1$ for every $k\le125$ with no bound on $n$, and tests a parameter-free model on that list. I did not read Erdős–Lacampagne–Selfridge (1993); Theorem 1 may well be there. It is not on the problem page.

Call $(n,k)$ *admissible* if $n\ge2k$ and no prime $p\le k$ divides $\binom nk$. Write $L_k=\mathrm{lcm}(1,\dots,k)$.


**Lean project.** The Lean files of this report are a Lake project at https://github.com/janjarosz05/0kwas (commit `6c4c16e`, Lean v4.34.1, Mathlib v4.34.1; modules `Kwas.Erdos1093`); `lake build` passes with no `sorry` and only the three standard axioms. The project was built from source by the isitsolved checker and accepted (no `sorry`, no extra axioms, no `native_decide`): https://isitsolved.com/lean/receipts/634fcf164b17 .

*This version adds Jan Jarosz as co-author and the link to the buildable Lean project; the mathematical content is unchanged.*

## 0. New in versions 2 and 3: the search goes to $k=200$ and finds nine new pairs; the model's dominant term is computed and it grows

*Version 3 extends the complete search from $k\le153$ to $k\le200$ and adds the pairs at $k=161,162,190$; the rest of this section is as in version 2.*

**(a) New pairs.** The complete search was rerun with 256-bit integers (`def4.c`; it reproduces the earlier list on the test values $k=28,95,96,100,106$) for $126\le k\le 200$ (for $k=162$ and $166\le k\le200$ with a port of the same algorithm to Python/numba using exact big integers at the leaves, validated on $k=100,126,148$; the largest single $k$ took $5.9\cdot10^{11}$ digit tests). It finds nine new pairs with deficiency 1:

| $k$ | $n$ | smooth term $n-i$, $i=$ | model $E(k)$ |
|---|---|---|---|
| 126 | 36859713316079485808433663 | 63 | 0.93 |
| 129 | 3180883073384828665489 | 64 | 0.085 |
| 136 | 11665201258379042011335164 | 68 | 0.48 |
| 148 | 192726492089012046660816823 | 73 | 0.27 |
| 148 | 8784118930086899149724 | 72 | 0.27 |
| 161 | 4850318488529659520035327155022817 | 80 | 0.022 |
| 162 | 4850318488529659520035327155022818 | 81 | 0.054 |
| 190 | 6617519208464295037527782616318420102084094 | 94 | 0.51 |
| 190 | 6617519208464295037527782616318420102084095 | 95 | 0.51 |


Each was verified independently with exact integer arithmetic (`verify_pairs.py`: $\binom nk$ is coprime to every prime $\le k$ and exactly one term $n-i$ is $k$-smooth). The model of §3 was computed before this search. Its four largest terms in $126\le k\le200$ are $k=126$ ($0.93$), $190$ ($0.51$), $136$ ($0.48$) and $148$ ($0.27$), and six of the nine pairs are at exactly these four $k$; the search at $k=190$ was run first because of the model. In total the model expects $3.3$ pairs in this range and the search finds 9. The pairs come in clusters that independent clocks do not produce: at $k=190$ the two values of $n$ are consecutive and share the smooth number $n-94$, and $(n,161)$, $(n+1,162)$ share theirs, since $\binom{n+1}{k+1}=\binom nk\cdot\frac{n+1}{k+1}$. I do not know whether these pairs appear in [ELS93]; they are not on the erdosproblems.com page. The complete list for $2\le k\le 200$ and all $n$ now has 185 pairs; still none with deficiency $>1$ beyond $k=42$.

**(b) Where the smooth term sits.** In the pairs with $k\ge95$ the smooth term is $n-i$ with $i=47,47,47,49,59,63,64,68,72,73,80,81,94,95$ for $k=95,96,96,100,106,126,129,136,148,148,161,162,190,190$: except for $k=106$ this is within 2 of $k/2$. The model explains this: in $E(k)=\sum_i(\dots)$ the largest term is at $i=\lfloor k/2\rfloor$ or $\lfloor k/2\rfloor-1$ at every spike I examined ($k=96,100,126,190,640,2656$), and that single term carries 30–50% of the sum.

**(c) Proposition (about the model, not about the problem).** Let $T(k)$ be the term $i=\lfloor k/2\rfloor$ of $E(k)$. Then
$$\log T(k)=C\,\frac{k}{\log k}+O\!\Big(\frac{k}{\log^2k}\Big),\qquad C=\sum_{m\ge1}\int_0^1\frac{h_m(\theta)}{(m+\theta)^2}\,d\theta=0.04367\ldots>0,$$
with $h_m(\theta)=\log(2-\theta)$ for odd $m$ and $\log(1-\theta)$ for even $m$.

*Sketch.* For a prime $p>\sqrt k$ write $k/p=m+\theta$. The factor of $p$ in $T(k)$ is $(1-m/p)\big(1-\theta+[\,i\bmod p\ge k\bmod p\,]\big)$. For $i=k/2$ the bracket is 1 exactly when $m$ is odd (then $\{i/p\}=(1+\theta)/2\ge\theta$) and 0 when $m$ is even and $\theta>0$. In words: a prime $p$ with $\lfloor k/p\rfloor$ odd may divide $n-i$ for free, which doubles the number of candidate divisors of $L_k$; a prime with $\lfloor k/p\rfloor$ even only costs. Summing $\log$ over primes with the prime number theorem ($p=k/x$, density $k\,dx/(x^2\log k)$) gives $C\,k/\log k$; primes $\le\sqrt k$ contribute $O(\sqrt k\log\log k)$ and the factors $(1-m/p)$ contribute $O(\sqrt k/\log k)$. The bands are $m=1$: $+0.2310$, $m=2$: $-0.1352$, $m\ge3$: $-0.0522$. I did not write out the uniformity needed near $\theta\to1$ (where $\log(1-\theta)$ is unbounded), so this is a sketch; the numbers below are exact evaluations of the model, not of the asymptotic formula.

| $k$ (20 even values from) | $\log_{10}T(k)$: min / median / max |
|---|---|
| 3 000 | $-18.1$ / $-14.8$ / $-11.2$ |
| 10 000 | $-28.6$ / $-22.6$ / $-16.6$ |
| 30 000 | $-19.8$ / $-15.1$ / $-11.7$ |
| 50 000 | $-12.6$ / $-8.6$ / $-0.8$ |
| 70 000 | $7.1$ / $11.0$ / $21.1$ |
| 100 000 | $-8.4$ / $-1.2$ / $6.2$ |
| 200 000 | $42.6$ / $51.7$ / $58.7$ |
| 1 000 000 | $593.7$ / $602.5$ / $611.2$ |

The second-order term is negative ($-0.237\,k/\log^2k$ from the variation of the prime density, and about $-2\sqrt k/\log k$), which is why $T(k)$ is tiny for $200<k<5\cdot10^4$ apart from isolated spikes, and why version 1 could not decide convergence from $k\le3000$.

**(d) What the model now says about the first question.** $E(k)\ge T(k)\to\infty$. The model, which has no fitted parameter and whose out-of-sample spikes at $k=95,96,100,126,136,148,190$ were confirmed by the search, predicts: **infinitely many pairs with deficiency $\ge1$; a few more for $200<k<5\cdot10^4$ at spikes ($k=640,2656,\dots$), and at least one for every $k$ beyond roughly $2\cdot10^5$**, with the smooth term at $i\approx k/2$ and $n-i$ a product of primes $p$ with $\lfloor k/p\rfloor$ odd times a few small prime powers. This is a heuristic, not a theorem.

**(e) The exact step missing for a proof.** Fix even $k$, $i=k/2$, and let $F$ be the set of primes $p\le k$ with $\lfloor k/p\rfloor$ odd ($|F|\sim\log2\cdot k/\log k$). One needs a subset $S\subset F$ such that $n=k/2+\prod_{p\in S}p$ satisfies $n\bmod p\ge k\bmod p$ for every prime $p\le k$ outside $S$ (and the digit conditions at $p\le\sqrt k$). There are $2^{|F|}$ candidates and each condition removes a proportion $\{k/p\}$ of residues; the proposition says the expected number of survivors is $e^{(C+o(1))k/\log k}$. A proof needs a lower bound for a sieve of dimension about $0.19\,k/\log k$ on a multiplicatively structured set of size $2^{|F|}$; no sieve gives a positive lower bound at that dimension, and I have no substitute. A constructive family (choosing $S$ by the Chinese remainder theorem) fails because the unknowns are the primes themselves.

## 1. Theorems (all proved in Lean)

By Kummer/Lucas, $p\nmid\binom nk$ iff every base-$p$ digit of $k$ is at most the corresponding digit of $n$ (`not_dvd_choose_iff_passes`).

**Lemma B** (`low_digits_of_dvd_term`). Let $(n,k)$ be admissible, $i\le n$, $p\le k$ prime and $p^a\mid n-i$. Then the lowest $a$ base-$p$ digits of $i$ dominate those of $k$.
*Proof.* $n\equiv i\pmod{p^a}$, so the lowest $a$ digits of $n$ are those of $i$; apply the digit rule. $\blacksquare$

**Theorem 1** (`prime_pow_le_of_dvd_term`, `smooth_term_dvd_lcm`). Let $(n,k)$ be admissible and $0\le i<k$. If $p\le k$ is prime and $p^e\mid n-i$, then $p^e\le k$. Consequently, if $n-i$ is $k$-smooth then $n-i$ divides $L_k$.
*Proof.* If $p^e>k$, then $k=k \bmod p^e\le n \bmod p^e=i \bmod p^e\le i<k$ (the first inequality is the digit rule for truncations), a contradiction. A number all of whose prime-power divisors are $\le k$ divides $L_k$. $\blacksquare$

**Corollary 2** (`lt_lcm_add_of_smooth_term`). If $\binom nk$ has deficiency $\ge1$, then $n<L_k+k$. So for every $k$ only finitely many $n$ give deficiency $\ge1$, and they can be listed by a finite search over divisors of $L_k$.

**Theorem 3** (`two_smooth_terms`). If $(n,k)$ is admissible and $n-i$, $n-j$ are both $k$-smooth with $i<j<k$, then $(n-j)(n-i)\le L_k\,(j-i)$. So deficiency $\ge2$ forces $(n-k)^2<k\,L_k$.
*Proof.* Both terms divide $L_k$ by Theorem 1, so their lcm does; their gcd divides $j-i$. $\blacksquare$

The same argument gives, for deficiency $d$: $(n-k)^d<L_k\,k^{d(d-1)/2}$ (the product of $d$ numbers divides their lcm times the product of pairwise gcds). This one is not in the Lean file.

Consequences for the two questions:

- Both questions are now questions about $k\to\infty$: for each $k$ the set of $n$ is finite and computable.
- Deficiency $\ge2$ needs an admissible $n$ below about $\sqrt{kL_k}$, deficiency $d$ needs one below about $L_k^{1/d}k^{(d-1)/2}$, while the least admissible $n$ is the Erdős–Selfridge function $g(k)$ of #1095. So a lower bound $g(k)>L_k^{1/2}k^{1/2}+k$ for large $k$ would give the second question. The expected size is $\log g(k)\approx0.79\,k/\log k$ against $\log L_k\sim k$, so this cannot work as it stands; what is missing is a count of admissible $n$ *near divisors of $L_k$*, not of admissible $n$ in general. That is the exact point where my attempt at the second question stops.

## 2. The complete list for $k\le125$

Program `def2.c`: for each $i<k$, Lemma B bounds the exponent of every prime in a smooth term $m=n-i$; the program runs over all such divisors $m$ of $L_k$ and tests $n=m+i$ with the digit rule. For $k\le80$ a second program (`def.c`) runs over *all* divisors of $L_k$ without Lemma B; the two lists are identical.

**Result.** For $2\le k\le125$ there are exactly **176** pairs $(n,k)$ with deficiency $\ge1$: 160 with deficiency 1 and **16 with deficiency $>1$**. The list is complete for these $k$ (all $n$), by Corollary 2.

- Deficiency $>1$ (complete for $k\le125$): $(n,k)=(44,8)$, $(74,10)$, $(174,12)$, $(239,14)$, $(5179,27)$, $(8413,28)$, $(8414,28)$, $(96622,42)$ with deficiency 2; $(46,10)$, $(47,10)$, $(241,16)$, $(2105,25)$, $(1119,27)$, $(6459,33)$ with deficiency 3; $(47,11)$ with deficiency 4; $(284,28)$ with deficiency 9. None has $k>42$. So any further binomial coefficient with deficiency $>1$ has $k\ge126$.
- The count of deficiency-1 pairs with $n\le10^5$ is 58, the number on the problem page.
- Pairs by range of $k$: 59 for $k\le20$, 78 for $21\le k\le40$, 24 for $41\le k\le60$, 10 for $61\le k\le80$, 4 for $81\le k\le100$, 1 for $101\le k\le125$.
- The five pairs with $k>80$, all of deficiency 1: $(216198140655426106847,\,95)$, $(7097627778251372,\,96)$, $(803511397376448532847,\,96)$, $(121557162475124854,\,100)$, $(275204387105968945551700859,\,106)$.

The full list is in `all_125.txt` (columns $k$, $n$, deficiency). For $126\le k\le140$ the program's 128-bit arithmetic overflows for some $i$; those $k$ are not covered.

**Logic net.** As a check that does not use the lemmas, a gate table was filled from brute force over $n\le60\,000$, $3\le k\le24$ with exact binomials: for every smooth term of an admissible pair it records the tokens $(k,p,v_p(n-i))$ and the lowest digits of $i$ and $k$. Over 56 pairs and 69 smooth terms, no gate with $p^a>k$ ever opens and no term violates $i \bmod p\ge k \bmod p$ for $p\mid n-i$; in 65 of the 78 pairs $(k,p)$ seen, the bound $p^a\le k$ is attained. The net's table is exactly Theorem 1 and Lemma B, which Lean then proves for all $n,k$.

## 3. Clock model

For fixed $k$ and $i$, a divisor $m$ of $L_k$ is given by its exponents $a_p$. By Lemma B the lowest $a_p$ digits of $n=m+i$ are known; the remaining digits are treated as independent uniform clocks, each passing with probability $(p-d)/p$ ($d$ = digit of $k$). The expected number of pairs with deficiency $\ge1$ is
$$E(k)=\sum_{i=0}^{k-1}\ \prod_{p\le k}\ \sum_{a=0}^{e_p}\ [\text{lowest }a\text{ digits of }i\text{ dominate those of }k]\prod_{j\ge a}\frac{p-d_j(k)}{p},\qquad p^{e_p}\le k<p^{e_p+1}.$$
No parameter is fitted.

| $k$ | observed pairs | model $\sum E(k)$ |
|---|---|---|
| 4–10 | 22 | 25.4 |
| 11–20 | 36 | 26.3 |
| 21–30 | 42 | 23.7 |
| 31–40 | 36 | 16.3 |
| 41–50 | 4 | 1.5 |
| 51–60 | 20 | 7.9 |
| 61–70 | 9 | 4.0 |
| 71–80 | 1 | 0.5 |

The model has the right shape and is low by a factor of about 2 for $k>20$ (pairs come in clusters, e.g. $n$ and $n+1$, which independent clocks do not produce).

**Out-of-sample test.** The model was computed for $81\le k\le3000$ before the search went beyond $k=80$. For $81\le k\le110$ it gives $\sum E=3.74$, concentrated at $k=96$ ($E=1.18$), $k=100$ ($1.18$), $k=99$ ($0.46$), $k=95$ ($0.33$); all other $k$ in that range have $E\le0.11$. The search then found 5 pairs, at $k=95$ (1), $96$ (2), $100$ (1) and $106$ (1, where $E=0.04$). For $111\le k\le125$ the model gives 0.10 and the search finds none.

**What the model says about the first question.** $\sum_{126\le k\le200}E(k)=3.3$ (largest terms at $k=126$: 0.93, $k=190$: 0.51, $k=136$: 0.48), then 0.30 for $201$–$400$, 0.73 for $401$–$700$, 0.01 for $701$–$1000$, 0.10 for $1001$–$2000$ and 0.37 for $2001$–$3000$ (of which 0.25 at $k=2656$). So the model expects roughly ten to twenty more pairs with $126\le k\le3000$ (allowing for the factor 2), and its terms do not decay regularly: they come in isolated spikes at special $k$. I could not decide from the model whether $\sum_kE(k)$ converges, which is the heuristic form of the first question. A naive average over $i$ gives $E(k)\approx k\,2^{\pi(k)}D(k)$ with $D(k)$ the admissible density, i.e. $\log E(k)\approx(0.693-0.788)\,k/\log k$, which would mean convergence and *finitely* many pairs of deficiency 1; but the sum is dominated by rare $(k,i)$ far from the average, so I do not trust this, and I state it only as the place where the heuristic is undecided.

For deficiency $>1$ I have no model, only the complete list above: 16 pairs, none with $43\le k\le125$.

## 4. Where it stops

- **First question.** Rigorous: reduced to divisors of $L_k$ (Theorem 1). Heuristic: undecided, see §3. A proof of "infinitely many" would need a family of $k$ with a forced admissible $n$ next to a divisor of $L_k$; the five large examples have $n\equiv-1$ or small residues modulo many prime powers, but I found no family.
- **Second question.** Rigorous: Theorem 3 and the complete list for $k\le125$. The step that fails is stated at the end of §1.
- $k>200$: the search costs about $5\cdot10^{11}$ digit tests per $k$ at $k\approx200$ and grows by a factor of about 10 per 25 steps in $k$; the next large model spike, $k=640$, is out of reach of exhaustive search.
- I did not read [ELS93] or Barreto's note, so overlap with them is possible.

## Lean source: `Erdos1093.lean`

```lean
import Mathlib

/-!
# Erdős Problem 1093: a smooth term of an admissible binomial coefficient divides lcm(1..k)

The logic net learned, from pairs with `n ≤ 120`, that clock `p` lets `(n, k)` through exactly when every
base-`p` digit of `k` is at most the corresponding digit of `n`. Here this rule is proved for all `n, k`
(it is Lucas's theorem in digit form), and the exceptional set of the problem is rewritten with it.
-/

namespace Erdos1093

/-- The learned gate, applied to all base-`p` digit pairs: every digit of `k` is `≤` that of `n`. -/
def passes (p : ℕ) : ℕ → ℕ → Prop
  | n, k => if _h : k = 0 ∨ p < 2 then True else k % p ≤ n % p ∧ passes p (n / p) (k / p)
decreasing_by
  have hk : k ≠ 0 := fun h0 ↦ _h (Or.inl h0)
  have hp : 2 ≤ p := by omega
  exact Nat.div_lt_self (Nat.pos_of_ne_zero hk) hp

theorem passes_zero (p n : ℕ) : passes p n 0 := by
  unfold passes; simp

theorem passes_step {p : ℕ} (hp : 2 ≤ p) (n : ℕ) {k : ℕ} (hk : k ≠ 0) :
    passes p n k ↔ k % p ≤ n % p ∧ passes p (n / p) (k / p) := by
  rw [passes]
  have h1 : 1 < p := by omega
  simp [hk, h1]

/-- **Kill rule.** For a prime `p`: `p ∤ C(n, k)` iff every base-`p` digit of `k` is at most that of `n`. -/
theorem not_dvd_choose_iff_passes {p : ℕ} (hp : p.Prime) :
    ∀ k n : ℕ, ¬ p ∣ n.choose k ↔ passes p n k := by
  have : Fact p.Prime := ⟨hp⟩
  intro k
  induction k using Nat.strong_induction_on with
  | _ k ih =>
    intro n
    by_cases hk : k = 0
    · subst hk
      simp [passes_zero, hp.one_lt.ne', Nat.dvd_one]
    · rw [passes_step hp.two_le n hk]
      have hlt : k / p < k := Nat.div_lt_self (Nat.pos_of_ne_zero hk) hp.two_le
      rw [← ih (k / p) hlt (n / p)]
      have hl := Choose.choose_modEq_choose_mod_mul_choose_div_nat (n := n) (k := k) (p := p)
      have hdvd : p ∣ n.choose k ↔ p ∣ (n % p).choose (k % p) * (n / p).choose (k / p) := by
        rw [Nat.dvd_iff_mod_eq_zero, Nat.dvd_iff_mod_eq_zero]
        unfold Nat.ModEq at hl
        rw [hl]
      rw [hdvd, hp.dvd_mul, not_or]
      have hdig : ¬ p ∣ (n % p).choose (k % p) ↔ k % p ≤ n % p := by
        constructor
        · intro h
          by_contra hlt'
          exact h (by rw [Nat.choose_eq_zero_of_lt (by omega)]; exact dvd_zero p)
        · intro hle hd
          have hnp : n % p < p := Nat.mod_lt _ hp.pos
          have hpos : 0 < (n % p).choose (k % p) := Nat.choose_pos hle
          have : p ∣ (n % p).factorial := by
            rw [← Nat.choose_mul_factorial_mul_factorial hle]
            exact Dvd.dvd.mul_right (Dvd.dvd.mul_right hd _) _
          exact absurd ((hp.dvd_factorial).1 this) (by omega)
      rw [hdig]

/-- Digit domination implies domination of every truncation: `k mod p^e ≤ n mod p^e`. -/
theorem passes_mod_pow {p : ℕ} (hp : 2 ≤ p) : ∀ (e n k : ℕ), passes p n k → k % p ^ e ≤ n % p ^ e := by
  intro e
  induction e with
  | zero => intro n k _; simp [Nat.mod_one]
  | succ e ih =>
    intro n k h
    by_cases hk : k = 0
    · subst hk; simp
    · rw [passes_step hp n hk] at h
      obtain ⟨h0, h1⟩ := h
      have h2 := ih (n / p) (k / p) h1
      rw [pow_succ', Nat.mod_mul, Nat.mod_mul]
      have := Nat.mul_le_mul_left p h2
      omega

/-- **Lemma.** Suppose no prime `p ≤ k` divides `C(n, k)`.  If `i < k` and a prime power `p^e` with `p ≤ k`
divides `n - i`, then `p^e ≤ k`. -/
theorem prime_pow_le_of_dvd_term {n k i p e : ℕ}
    (hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k)
    (hi : i < k) (hin : i ≤ n) (hp : p.Prime) (hpk : p ≤ k) (hd : p ^ e ∣ n - i) : p ^ e ≤ k := by
  by_contra hlt
  have hpass := (not_dvd_choose_iff_passes hp k n).1 (hadm p hp hpk)
  have h1 := passes_mod_pow hp.two_le e n k hpass
  have h2 : i % p ^ e = n % p ^ e := (Nat.modEq_iff_dvd' hin).2 hd
  have h3 : k % p ^ e = k := Nat.mod_eq_of_lt (by omega)
  have h4 : i % p ^ e ≤ i := Nat.mod_le _ _
  omega

/-- **Theorem.** Suppose no prime `p ≤ k` divides `C(n, k)` (the deficiency is defined).  If `i < k` and
`n - i` is `k`-smooth (nonzero, all prime factors `≤ k`), then `n - i` divides `lcm(1, …, k)`. -/
theorem smooth_term_dvd_lcm {n k i : ℕ}
    (hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k)
    (hi : i < k) (hin : i ≤ n) (hsmooth : ∀ q : ℕ, q.Prime → q ∣ n - i → q ≤ k) :
    n - i ∣ (Finset.Icc 1 k).lcm id := by
  rw [Nat.dvd_iff_prime_pow_dvd_dvd]
  intro p e hp hd
  rcases Nat.eq_zero_or_pos e with he | he
  · subst he; simp
  · have hpd : p ∣ n - i := dvd_trans (dvd_pow_self p (by omega)) hd
    have hpk := hsmooth p hp hpd
    have hle := prime_pow_le_of_dvd_term hadm hi hin hp hpk hd
    have hmem : p ^ e ∈ Finset.Icc 1 k := Finset.mem_Icc.2 ⟨Nat.pos_of_ne_zero (pow_ne_zero e hp.ne_zero), hle⟩
    exact Finset.dvd_lcm (f := id) hmem

/-- **Corollary.** If the deficiency of `C(n, k)` is defined and at least one of `n, n-1, …, n-k+1` is
`k`-smooth, then `n < lcm(1, …, k) + k`.  So for each `k` only finitely many `n` have deficiency `≥ 1`. -/
theorem lt_lcm_add_of_smooth_term {n k i : ℕ}
    (hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k)
    (hi : i < k) (hin : i ≤ n) (hsmooth : ∀ q : ℕ, q.Prime → q ∣ n - i → q ≤ k) :
    n < (Finset.Icc 1 k).lcm id + k := by
  have hd := smooth_term_dvd_lcm hadm hi hin hsmooth
  have hpos : 0 < (Finset.Icc 1 k).lcm id := by
    apply Nat.pos_of_ne_zero
    rw [Ne, Finset.lcm_eq_zero_iff]
    simp
  have := Nat.le_of_dvd hpos hd
  omega

/-- Digit domination is inherited by truncations: the lowest `a` digits also dominate. -/
theorem passes_mod {p : ℕ} (hp : 2 ≤ p) : ∀ (a n k : ℕ), passes p n k → passes p (n % p ^ a) (k % p ^ a) := by
  intro a
  induction a with
  | zero => intro n k _; simp [Nat.mod_one, passes_zero]
  | succ a ih =>
    intro n k h
    by_cases hk0 : k % p ^ (a + 1) = 0
    · rw [hk0]; exact passes_zero _ _
    · have hk : k ≠ 0 := by rintro rfl; simp at hk0
      rw [passes_step hp n hk] at h
      obtain ⟨h0, h1⟩ := h
      rw [passes_step hp _ hk0]
      have hdvd : p ∣ p ^ (a + 1) := dvd_pow_self p (by omega)
      refine ⟨?_, ?_⟩
      · rw [Nat.mod_mod_of_dvd _ hdvd, Nat.mod_mod_of_dvd _ hdvd]; exact h0
      · rw [pow_succ', Nat.mod_mul_right_div_self, Nat.mod_mul_right_div_self]
        exact ih _ _ h1

/-- **Lemma B.** If no prime `q ≤ k` divides `C(n, k)`, `i ≤ n`, and `p^a` divides `n - i` (`p ≤ k` prime), then
the lowest `a` base-`p` digits of `i` dominate those of `k`. -/
theorem low_digits_of_dvd_term {n k i p a : ℕ}
    (hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k)
    (hin : i ≤ n) (hp : p.Prime) (hpk : p ≤ k) (hd : p ^ a ∣ n - i) :
    passes p (i % p ^ a) (k % p ^ a) := by
  have hpass := (not_dvd_choose_iff_passes hp k n).1 (hadm p hp hpk)
  have h2 : i % p ^ a = n % p ^ a := (Nat.modEq_iff_dvd' hin).2 hd
  rw [h2]
  exact passes_mod hp.two_le a n k hpass

/-- **Two smooth terms.** If the deficiency is defined and both `n - i` and `n - j` (`i < j < k`) are `k`-smooth,
then `(n - j) * (n - i) ≤ lcm(1, …, k) * (j - i)`.  So deficiency `≥ 2` forces `(n - k)^2 < k * lcm(1, …, k)`. -/
theorem two_smooth_terms {n k i j : ℕ}
    (hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k)
    (hij : i < j) (hj : j < k) (hjn : j ≤ n)
    (hsi : ∀ q : ℕ, q.Prime → q ∣ n - i → q ≤ k) (hsj : ∀ q : ℕ, q.Prime → q ∣ n - j → q ≤ k) :
    (n - j) * (n - i) ≤ (Finset.Icc 1 k).lcm id * (j - i) := by
  have hdi := smooth_term_dvd_lcm hadm (by omega) (by omega) hsi
  have hdj := smooth_term_dvd_lcm hadm hj hjn hsj
  have hpos : 0 < (Finset.Icc 1 k).lcm id := by
    apply Nat.pos_of_ne_zero
    rw [Ne, Finset.lcm_eq_zero_iff]
    simp
  have hl : Nat.lcm (n - j) (n - i) ≤ (Finset.Icc 1 k).lcm id := Nat.le_of_dvd hpos (Nat.lcm_dvd hdj hdi)
  have hg : Nat.gcd (n - j) (n - i) ∣ j - i := by
    have h1 : Nat.gcd (n - j) (n - i) ∣ (n - i) - (n - j) :=
      Nat.dvd_sub (Nat.gcd_dvd_right _ _) (Nat.gcd_dvd_left _ _)
    have h2 : (n - i) - (n - j) = j - i := by omega
    rwa [h2] at h1
  have hg' : Nat.gcd (n - j) (n - i) ≤ j - i := Nat.le_of_dvd (by omega) hg
  calc (n - j) * (n - i) = Nat.gcd (n - j) (n - i) * Nat.lcm (n - j) (n - i) := (Nat.gcd_mul_lcm _ _).symm
    _ ≤ (j - i) * (Finset.Icc 1 k).lcm id := Nat.mul_le_mul hg' hl
    _ = (Finset.Icc 1 k).lcm id * (j - i) := Nat.mul_comm _ _

end Erdos1093

#print axioms Erdos1093.smooth_term_dvd_lcm
#print axioms Erdos1093.lt_lcm_add_of_smooth_term
#print axioms Erdos1093.low_digits_of_dvd_term
#print axioms Erdos1093.two_smooth_terms
```

