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

Numbers $n$ such that the perfect deficiency of $n$ is $\le 10$.

The perfect deficiency of $n$ (A109883) is the remainder after greedily subtracting from $n$ its divisors in increasing order, skipping any divisor larger than the current remainder.

References:

@[expose] public sectionnamespace OeisA108864open Nat Finset Int

The perfect deficiency of $n$ (A109883): the remainder after greedily subtracting from $n$ its divisors in increasing order, skipping any divisor larger than the current remainder.

def perfectDeficiency (n : ) : := (List.range (n + 1)).foldl (fun m d => if d n d m then m - d else m) n

The condition for a number $n$ to be in the sequence. It satisfies $0 < n$ and its perfect deficiency is $\le 10$.

def A (n : ) : Prop := 0 < n perfectDeficiency n 10instance : DecidablePred A := DecidablePred A DecidablePred fun n 0 < n perfectDeficiency n 10 All goals completed! 🐙

The primary defining sequence a. $a(n)$ is the $n$-th number (0-indexed) such that its perfect deficiency is $\le 10$.

noncomputable def a (n : ) : := n.nth A

Term theorems verifying the first few values of the sequence against the official OEIS b-file

h1:A 1hcnt:count A 1 = 0a 0 = 1 h1:A 1hcnt:count A 1 = 0this:nth A (count A 1) = 1a 0 = 1 rwa [h1:A 1hcnt:count A 1 = 0this:nth A 0 = 1a 0 = 1h1:A 1hcnt:count A 1 = 0this:nth A 0 = 1a 0 = 1 at thish2:A 2hcnt:count A 2 = 1a 1 = 2 h2:A 2hcnt:count A 2 = 1this:nth A (count A 2) = 2a 1 = 2 rwa [h2:A 2hcnt:count A 2 = 1this:nth A 1 = 2a 1 = 2h2:A 2hcnt:count A 2 = 1this:nth A 1 = 2a 1 = 2 at thish3:A 3hcnt:count A 3 = 2a 2 = 3 h3:A 3hcnt:count A 3 = 2this:nth A (count A 3) = 3a 2 = 3 rwa [h3:A 3hcnt:count A 3 = 2this:nth A 2 = 3a 2 = 3h3:A 3hcnt:count A 3 = 2this:nth A 2 = 3a 2 = 3 at thish4:A 4hcnt:count A 4 = 3a 3 = 4 h4:A 4hcnt:count A 4 = 3this:nth A (count A 4) = 4a 3 = 4 rwa [h4:A 4hcnt:count A 4 = 3this:nth A 3 = 4a 3 = 4h4:A 4hcnt:count A 4 = 3this:nth A 3 = 4a 3 = 4 at thish5:A 5hcnt:count A 5 = 4a 4 = 5 h5:A 5hcnt:count A 5 = 4this:nth A (count A 5) = 5a 4 = 5 rwa [h5:A 5hcnt:count A 5 = 4this:nth A 4 = 5a 4 = 5h5:A 5hcnt:count A 5 = 4this:nth A 4 = 5a 4 = 5 at this

Is $1155$ the last odd number in this sequence? ($1155$ is the $59$th term starting from $1$, corresponding to $a(58) = 1155$).

@[category research open, AMS 11] theorem conjecture : answer(sorry) n > 58, Even (a n) := True n > 58, Even (OeisA108864.a n) All goals completed! 🐙end OeisA108864