\documentclass[11pt,letterpaper]{article} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[hmargin=1in,vmargin=0.95in]{geometry} \usepackage{amsmath,amssymb,amsthm} \usepackage{booktabs} \usepackage{microtype} \usepackage[hidelinks]{hyperref} \newtheorem{theorem}{Theorem} \newtheorem{proposition}[theorem]{Proposition} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}[theorem]{Corollary} \theoremstyle{remark} \newtheorem{remark}[theorem]{Remark} \hypersetup{pdftitle={Erdos problems 385 and 430: the size of F(n)-n for almost all n}} \newcommand{\cS}{\mathcal S} \begin{document} \begin{center} {\Large\bfseries Erd\H{o}s Problems \#385 and \#430:\\ the size of $F(n)-n$ for almost all $n$\par} \medskip Aafi Khan Malek\\ Independent researcher\\ \href{mailto:aafimalek2032@gmail.com}{\texttt{aafimalek2032@gmail.com}}\par \smallskip 26 November 2026; revised 2 December 2026 \end{center} \begin{abstract} Let $F(n)=\max\{m+p(m): mn$ for all large $n$ and whether $F(n)-n\to\infty$; Erd\H{o}s Problem \#430 is equivalent to the first question. Both questions remain open. We prove that if $T(X)=o(\log X)$, then $F(n)>n+T(X)$ for all but $o(X)$ integers $nn$ for all sufficiently large $n$, and (ii) does $F(n)-n\to\infty$? They add that possibly $F(n)\ge n+(1-o(1))\sqrt n$ always (iii); trivially $F(n)\le n+\sqrt n$. These form Erd\H{o}s Problem \#385 \cite{bloom}. Problem \#430, from Erd\H{o}s and Graham \cite{erdosgraham}, asks whether for large $n$ the decreasing sequence of integers $aq-p$, then $m$ is composite and $m+p(m)>m+q-p\ge q+1=n$, a contradiction. Their strict roughness bound includes the twin-prime gaps; summing their bound for dyadic ranges of the left endpoint gives the stated estimate. This argument does not give our growing threshold or the square-root margin. Tong \cite{tong}, Theorem 1.1, proves a related overlapping backward square-root estimate with shrinking margin $1-(\log n)^{-\kappa}$ for fixed $\kappa>0$, outside $O_{\kappa,A}(X(\log X)^{-A})$ exceptions for any fixed $A>0$, and obtains forward results for Problem \#463. The fixed-margin statement here is not a claim of a stronger analytic bound. The Lean reductions, exact finite computations, and the scope of the formal square-root result are described separately below. \paragraph{Results.} Question (i) and question (ii) for every large $n$ remain open. We give almost-all results, ending with the strongest possible one. \begin{center} \small \begin{tabular}{p{0.42\linewidth}p{0.2\linewidth}p{0.3\linewidth}} \toprule Statement & Holds for & Status \\ \midrule $F(n)>n+T$, any fixed $T$ & almost all $n$ & Lean (Theorem~\ref{thm:lean}) \\ $F(n)>n+T(X)$ for $n0$ & almost all $n$ & Lean, no analytic hypotheses (Theorem~\ref{thm:sqrt}, density zero) \\ $F(n)>n$ & all large $n$ & open; parity barrier \\ \bottomrule \end{tabular} \end{center} \section{Elementary reductions} The following statements are proved in Lean~4 with mathlib (file \texttt{Erdos430.lean}); $F(n)$ is defined as a supremum, so $F(n)=0$ when no composite $mz-j$. \section{A variance bound for reduced residues in an interval} Let $P$ be a finite set of primes, $Q=\prod_{q\in P}q$ and $N=\prod_{q\in P}(q-1)$. Let $I$ be a set of $L\ge1$ consecutive integers. For a choice $\omega=(\omega_q)_{q\in P}$ of one residue class modulo each $q\in P$, let $\cS(\omega)$ be the number of $j\in I$ with $j\not\equiv\omega_q\pmod q$ for every $q\in P$. There are $Q$ choices of $\omega$. \begin{lemma}\label{lem:pairs} For every $m\ge1$, the number of ordered pairs $(j,j')\in I^2$ with $j\ne j'$ and $m\mid j-j'$ is at most $L(L-1)/m$. \end{lemma} \begin{proof} For fixed $j$, the $j'\in I$ with $j'\equiv j\pmod m$ form a progression of difference $m$ inside an interval of length $L-1$, so there are at most $\lfloor (L-1)/m\rfloor+1$ of them, $j$ included. \end{proof} \begin{lemma}\label{lem:var} $\sum_\omega \cS(\omega)=LN$ and $\sum_\omega \cS(\omega)^2\le LN+L(L-1)N^2/Q$. Consequently \[ \#\{\omega:\cS(\omega)=0\}\le \frac{Q^2}{LN}, \] so the variance of $\cS$ is at most its mean. \end{lemma} \begin{proof} For a fixed $j$, exactly $N$ choices of $\omega$ avoid $j$. For $j\ne j'$, the number of $\omega$ avoiding both is $\prod_{q\in P}\bigl(q-2+[q\mid j-j']\bigr)$, since modulo $q$ the residue $\omega_q$ must avoid one class if $q\mid j-j'$ and two otherwise. Expanding the product over subsets $s\subseteq P$ gives $\sum_s [\prod_{q\in s}q\mid j-j']\prod_{q\in P\setminus s}(q-2)$. Summing over pairs and applying Lemma~\ref{lem:pairs} with $m=\prod_{q\in s}q$, \[ \sum_{j\ne j'}\prod_{q\in P}\bigl(q-2+[q\mid j-j']\bigr) \le L(L-1)\sum_{s\subseteq P}\prod_{q\in s}\frac1q\prod_{q\in P\setminus s}(q-2) =L(L-1)\prod_{q\in P}\Bigl(q-2+\frac1q\Bigr)=L(L-1)\frac{N^2}{Q}, \] because $q-2+1/q=(q-1)^2/q$. With $\mu=LN/Q$ this gives $\sum_\omega(\cS-\mu)^2=\sum_\omega\cS^2-Q\mu^2\le LN-LN^2/Q\le LN$, and $\#\{\cS=0\}\,\mu^2\le LN$. \end{proof} For general moduli, the bound ``variance at most mean'' for reduced residues in intervals is attributed in the literature to Hausman and Shapiro \cite{hs}; we have not consulted that paper. The proof above is short and self-contained, which made it practical to formalize. \section{\texorpdfstring{Thresholds up to $o(\log X)$, formally verified}{Thresholds up to o(log X), formally verified}} \begin{theorem}\label{thm:lean} For integers $X\ge0$, $T\ge0$ and $J\ge1$, with $z=2J+T$ and $z\#$ the product of the primes up to $z$, \[ \#\{nz$, and $G(n)>z-j\ge T$. The map $n\mapsto\omega(n)$ is injective on every block of $z\#$ consecutive integers, by the Chinese remainder theorem. So $\#\{n0$, the set of $n$ with $F(n)0$, $\int_{-T}^{T}\bigl|\sum_{n\le M}b_nn^{-it}\bigr|^2dt=(2T+O(M))\sum_{n\le M}|b_n|^2$. \end{lemma} \begin{lemma}[Prime number theorem]\label{lem:pnt} $\pi(y)=\operatorname{li}(y)+O\bigl(y\,e^{-c\sqrt{\log y}}\bigr)$, and $\sum_{p\le y}1/p=\log\log y+M+O\bigl(e^{-c\sqrt{\log y}}\bigr)$, for an absolute $c>0$. \end{lemma} Both follow by partial summation from $\psi(y)=y+O\bigl(y\,e^{-c\sqrt{\log y}}\bigr)$ \cite[Ch.~18]{davenport}. \begin{lemma}[Prime sums on the $1$-line]\label{lem:vk} There is an absolute $c>0$ such that, for $Y$ large, $\sqrt Y/4\le P_1P_2\ge p$, each $m$ has at most one representation $m=pk$, so $a_m\in\{0,1\}$, and $a_m$ is supported in $[P_1\sqrt Y,3P_2\sqrt Y]\subset[Y/2,3Y]$. \emph{Step 1: witnesses.} If $a_m=1$ and $N-h\le m0$ and $v\in\mathbb R$ let \[ F_\vartheta(v)=\frac1\vartheta\sum_m\frac{a_m}{m}\,\phi\Bigl(\frac{v-\log m}{\vartheta}\Bigr). \] If $F_\theta(\log x)>0$, some $m$ with $a_m=1$ lies in $[xe^{-\theta},x]$. The Fourier transform of $F_\vartheta$ is \[ \int F_\vartheta(v)e^{-ivt}dv=A(1+it)\,\hat\phi(\vartheta t),\qquad \hat\phi(\xi)=\int\phi(s)e^{-is\xi}ds, \] and $|\hat\phi(\xi)|\le1$, $|\hat\phi(\xi)-1|\le|\xi|$ and $|\hat\phi(\xi)|\le C_\phi\xi^{-2}$. \emph{Step 3: the long average.} Let $\log(Y-1)\le v\le\log((1+\eta)Y)$. For each $p$, the primes $k$ with $\log k\in[w-\Theta,w]$, where $w=v-\log p$, lie in $[\sqrt Y,3\sqrt Y]$. By Lemma~\ref{lem:pnt} and partial summation against the function $u\mapsto\phi((w-\log u)/\Theta)/u$, whose total variation is $O(e^{-w})$, \[ \frac1\Theta\sum_k\frac1k\,\phi\Bigl(\frac{w-\log k}{\Theta}\Bigr) =\frac1\Theta\int\phi\Bigl(\frac{w-\log u}{\Theta}\Bigr)\frac{du}{u\log u}+O\Bigl(\frac{e^{-c\sqrt w}}{\Theta}\Bigr) =\frac{1+o(1)}{w}, \] because $\Theta=(\log Y)^{-6}$ and $w\asymp\log Y$. Since $w\le\frac12\log Y+O(1)$, Lemma~\ref{lem:pnt} gives \[ F_\Theta(v)\ge\frac{2+o(1)}{\log Y}\sum_{P_1\le p\le P_2}\frac1p =\frac{2+o(1)}{\log Y}\cdot\frac{\log(P_2/P_1)}{\log P_1}\ge\frac{\varepsilon}{10\log^2Y}. \] \emph{Step 4: the mean square.} By Plancherel, \[ \int_{\mathbb R}|F_\theta(v)-F_\Theta(v)|^2dv=\frac1{2\pi}\int_{\mathbb R}|A(1+it)|^2\,|\hat\phi(\theta t)-\hat\phi(\Theta t)|^2dt. \] First, $\sum_ma_m/m^2\le\sum_pp^{-2}\sum_kk^{-2}\ll\varepsilon/(Y\log^2Y)$ and $\sum_kk^{-2}\ll1/(\sqrt Y\log Y)$. (a) For $|t|\le T_0$ the weight is at most $(2\Theta T_0)^2$, since $\theta\le\Theta$. By Lemma~\ref{lem:mvt} applied to $A$, this range contributes $\ll(\Theta T_0)^2(T_0+3Y)\,\varepsilon/(Y\log^2Y)\ll\varepsilon(\log Y)^{-8}$. (b) For $T_0\le|t|\le Y^2$ the weight is at most $4\min(1,C_\phi^2(\theta t)^{-4})$, and $|A(1+it)|\le M\,|K(1+it)|$ with $M=\sup_{T_0\le|t|\le Y^2}|P(1+it)|$. Splitting dyadically above $1/\theta$ and applying Lemma~\ref{lem:mvt} to $K$, \[ \int\min\bigl(1,(\theta t)^{-4}\bigr)|K(1+it)|^2dt\ll\Bigl(\frac1\theta+\sqrt Y\Bigr)\frac{1}{\sqrt Y\log Y}\ll\frac{1}{\varepsilon\log Y}, \] because $1/\theta=32\sqrt Y/\varepsilon$. By Lemma~\ref{lem:vk}, $M\ll(\log Y)^{-4}$, so this range contributes $\ll(\log Y)^{-9}/\varepsilon$. (c) For $|t|\ge Y^2$ the weight is at most $4C_\phi^2(\theta t)^{-4}$, and Lemma~\ref{lem:mvt} on dyadic ranges bounds the contribution by $\ll\theta^{-4}Y^{-6}\cdot\varepsilon/(Y\log^2Y)\ll Y^{-3}$. Altogether $\int|F_\theta-F_\Theta|^2dv=o(\varepsilon^2/\log^4Y)$ as $Y\to\infty$ with $\varepsilon$ fixed. \emph{Step 5: counting.} Let $E$ be the set of $v\in[\log(Y-1),\log((1+\eta)Y)]$ with $F_\theta(v)\le0$. On $E$, $|F_\theta-F_\Theta|\ge F_\Theta\ge\varepsilon/(10\log^2Y)$, so $\operatorname{meas}(E)=o(1)$ by Steps~3 and~4. Now let $N\in[Y,(1+\eta)Y]$ be an integer with $G(N)<(1-\varepsilon)\sqrt N$. If $F_\theta(\log x)>0$ for some $x\in[N-1,N)$, there is $m$ with $a_m=1$ and $xe^{-\theta}\le m\le x$; then $m0$. The proof gives no information about individual $n$: the witnesses are semiprimes $pk$ with $p$ close to $\sqrt n$, and showing that every interval $[n-h,n)$ contains one is a binary problem of the same kind as question (i). \end{remark} \begin{remark}[Formal verification]\label{rem:leansqrt} The deduction of Theorem~\ref{thm:sqrt} from the analytic inputs is checked in Lean~4 (directory \texttt{Erdos430Sqrt}). The theorem \texttt{sqrt\_almost\_all} has three hypotheses: the inequality $\int_{-T}^{T}|\sum_{n\le N}b_nn^{-it}|^2dt\le(2T+CN)\sum_{n\le N}|b_n|^2$ from Lemma~\ref{lem:mvt}; the bound $|\vartheta(x)-x|\le Cx(\log x)^{-10}$ for $x\ge2$, a consequence of Lemma~\ref{lem:pnt}; and, for $Y\ge Y_0$, $\sqrt Y/4\le P_1$, $P_2\le4\sqrt Y$ and $1\le|t|\le Y^2$, the bound $|\sum_{P_1\le p\le P_2}p^{-1-it}|\le C\bigl(1/(|t|\log Y)+(\log Y)^{-5}\bigr)$, a consequence of Lemma~\ref{lem:vk}. From these, Lean proves that for every $\varepsilon>0$ the number of $n31/32$, for Dedekind zeta functions. We specialize their theorem to $\mathbb Q$. Lean verifies the rational Dedekind Dirichlet-series identity and uses uniqueness of analytic continuation to identify the resulting function with mathlib's \texttt{riemannZeta} in the upper and lower half-planes. Thus the eventual nonvanishing premise disappears from \texttt{Erdos385.erdos\_385.variants.}\allowbreak \texttt{lb\_almost\_all\_unconditional}. The terminal axiom audit lists exactly \texttt{propext}, \texttt{Classical.choice}, and \texttt{Quot.sound}. The assertion checked here is density zero for each fixed $\varepsilon>0$; it does not formalize the written quantitative error rate or prove the pointwise conjectures. The exact source, dependency pins, and replay instructions are in the \href{https://github.com/Aafimalek/erdos-385-almost-all/tree/30445bf4b495fb57cc6c35ca349878d9cb95bff5/research/dedekind-audit}{archived Lean proof}. \section{A heuristic for the worst case, and the data} Theorem~\ref{thm:sqrt} concerns almost all $n$. Here we estimate the worst $n$ in a range. For $G(n)\ge(1-\eta)\sqrt n$ one needs primes $(1-\eta)\sqrt n\le p\le k$ with $n-pk\le p-(1-\eta)\sqrt n$. Write $y=\sqrt n$ and $p=y-a$. Treating ``$p$ is prime'', ``$\lfloor n/p\rfloor$ is prime'' and the residue $n\bmod p$ as independent, the expected number of such pairs is \[ \lambda(\eta)\approx\sum_{0\le a\le\eta y}\frac{1}{\log^2 y}\cdot\frac{\eta y-a}{y} \approx\frac{2\eta^2\sqrt n}{\log^2 n}. \] If this count is roughly Poisson, then $\Pr\bigl(G(n)<(1-\eta)\sqrt n\bigr)\approx e^{-\lambda(\eta)}$. Between jumps $G$ decreases by one per step, so its values on $[X,2X]$ behave like about $X^{1/2+o(1)}$ independent trials. Setting $\lambda(\eta)=\tfrac12\log X$ suggests \begin{equation}\label{eq:pred} \min_{X\le n<2X}\frac{G(n)}{\sqrt n}= 1-(C+o(1))\,\frac{(\log X)^{3/2}}{X^{1/4}}, \qquad C=\tfrac12 . \end{equation} Only composites $m\ge n-\sqrt n$ can satisfy $m+p(m)\ge n$, because $p(m)\le\sqrt m$. So $G(n)$ is determined by the least prime factors in a window of length $\sqrt n$, and a segmented sieve computes it exactly. We did this for every $n<5\times10^{11}$. This repeats the forum searches as an independent check and finds exactly the $100$ known bad $n$. We checked the program against direct implementations of both definitions for $n\le6000$, against OEIS A322293, and against an independent computation of the distribution of $G(n)$ for $n\le10^6$. We also recomputed $G$ from the definition at every reported minimum, and the outputs do not depend on the block size or the number of threads. On $[1.1\times10^9,1.26\times10^{11}]$ the minimum of $G$ is $23989$, the value reported on the forum for that range. Table~\ref{tab:ratio} gives, for each dyadic range, the minimum $r$ of $G(n)/\sqrt n$, the $n$ attaining it, and the empirical constant $\hat C=(1-r)\,n^{1/4}(\log n)^{-3/2}$. Beyond $2^{24}$ the values of $\hat C$ lie between $0.51$ and $0.58$, close to the heuristic value $\tfrac12$. This agrees with \eqref{eq:pred}; the range is too short to determine the exponents independently. \begin{table}[ht] \centering\small \begin{tabular}{rrrrr} \toprule $k$ & $\min G$ & $n$ attaining $\min G/\sqrt n$ & $r=\min G/\sqrt n$ & $\hat C$ \\ \midrule 16 & 9 & 71017 & 0.0338 & 0.422 \\ 17 & 31 & 167129 & 0.0758 & 0.448 \\ 18 & 0 & 267672 & 0.0000 & 0.515 \\ 19 & 161 & 569929 & 0.2133 & 0.448 \\ 20 & 255 & 1064423 & 0.2472 & 0.468 \\ 21 & 581 & 3187519 & 0.3523 & 0.472 \\ 22 & 775 & 5540897 & 0.3292 & 0.532 \\ 23 & 1223 & 8401817 & 0.4219 & 0.489 \\ 24 & 2139 & 28659247 & 0.5012 & 0.513 \\ 25 & 3173 & 38133367 & 0.5138 & 0.524 \\ 26 & 4865 & 88353283 & 0.5448 & 0.564 \\ 27 & 7331 & 144664921 & 0.6095 & 0.526 \\ 28 & 10429 & 275399221 & 0.6284 & 0.559 \\ 29 & 16581 & 768272587 & 0.6883 & 0.561 \\ 30 & 23989 & 1126090883 & 0.7149 & 0.549 \\ 31 & 34965 & 2165890849 & 0.7513 & 0.538 \\ 32 & 52075 & 5032768333 & 0.7696 & 0.581 \\ 33 & 75827 & 8986525021 & 0.8041 & 0.550 \\ 34 & 111149 & 18448541393 & 0.8284 & 0.550 \\ 35 & 158303 & 35862919733 & 0.8452 & 0.562 \\ 36 & 231787 & 109984719899 & 0.8701 & 0.584 \\ 37 & 331323 & 153743427961 & 0.8820 & 0.565 \\ \bottomrule \end{tabular} \caption{Minima over $2^k\le n<2^{k+1}$. The column $\min G$ is the minimum of $G$ itself, which may be attained at a different $n$.} \label{tab:ratio} \end{table} \section{What remains} Part (i), and with it Problem \#430, is open. It asks for a witness for every $n$, and the analyses in \cite{tao} indicate this needs progress on the parity problem. Part (ii) for every large $n$ implies part (i). For almost all $n$, Theorem~\ref{thm:sqrt} settles all three questions. What remains is the exceptional set: we show it has density zero (indeed it is $O(X(\log X)^{-A})$ below $X$), but not that it is finite. \section*{Use of AI tools} The author used AI systems (OpenAI Codex and Anthropic Claude). They searched the literature, wrote and checked the search program, found the proof of Lemma~\ref{lem:var} and the arguments of Theorems~\ref{thm:lean} and~\ref{thm:sqrt}, wrote the Lean formalization, and drafted the text. The author checked the arguments, ran the computations and built the Lean proofs. The Lean kernel checks Proposition~\ref{prop:red}, Lemma~\ref{lem:var} and Theorem~\ref{thm:lean} independently of how they were produced. It also checks the deduction of Theorem~\ref{thm:sqrt} from the three analytic inputs listed in Remark~\ref{rem:leansqrt}. Those inputs are classical theorems, but they are hypotheses in that earlier Lean route. The unconditional density-zero theorem uses the separate route described above. ChatGPT assisted with that route, including the bridge to the cited AxiomProver formalization, and with the literature and verification-status update. The author takes full responsibility for the content. \begin{thebibliography}{11} \bibitem{bloom} T.~F. Bloom, \emph{Erd\H{o}s Problems \#385 and \#430}, with forum threads, \url{https://www.erdosproblems.com/385}, \url{https://www.erdosproblems.com/430}. \bibitem{davenport} H.~Davenport, \emph{Multiplicative Number Theory}, 3rd ed., Graduate Texts in Mathematics \textbf{74}, Springer, 2000. \bibitem{erdos79} P.~Erd\H{o}s, \emph{Some unconventional problems in number theory}, Acta Math.\ Acad.\ Sci.\ Hungar.\ \textbf{33} (1979), 71--80. \bibitem{erdosgraham} P.~Erd\H{o}s and R.~L.~Graham, \emph{Old and new problems and results in combinatorial number theory}, Monographies de L'Enseignement Math\'ematique \textbf{28}, 1980. \bibitem{gafnitao} A.~Gafni and T.~Tao, \emph{Rough numbers between consecutive primes}, preprint (2025), arXiv:2508.06463. \bibitem{hs} M.~Hausman and H.~N.~Shapiro, \emph{On the mean square distribution of primitive roots of unity}, Comm.\ Pure Appl.\ Math.\ \textbf{26} (1973), 539--547. \bibitem{mvhilbert} H.~L.~Montgomery and R.~C.~Vaughan, \emph{Hilbert's inequality}, J.\ London Math.\ Soc.\ (2) \textbf{8} (1974), 73--82. \bibitem{oeis} OEIS Foundation Inc., \emph{The On-Line Encyclopedia of Integer Sequences}, \url{https://oeis.org}, sequences A322292 and A322293. \bibitem{titchmarsh} E.~C.~Titchmarsh, \emph{The Theory of the Riemann Zeta-Function}, 2nd ed., revised by D.~R.~Heath-Brown, Oxford, 1986. \bibitem{tao} T.~Tao, \emph{Erd\H{o}s problem \#385, the parity problem, and Siegel zeroes}, blog post and comments, 19 August 2024, \url{https://terrytao.wordpress.com/2024/08/19/erdos-problem-385-the-parity-problem-and-siegel-zeroes/}. \bibitem{tong} M.~Tong, \emph{Erd\H{o}s problems \#385 and \#463 for almost all integers}, preprint (2026), \href{https://hexagonmath.org/2611.01517v1}{hexagon:2611.01517v1}. \bibitem{curetonthorner} D.~Cureton and J.~Thorner, \emph{A quasi-Riemann hypothesis for Dedekind zeta functions}, preprint (2026), \href{https://hexagonmath.org/2610.00200v2}{hexagon:2610.00200v2}, Theorem~1.1. Lean formalization generated by AxiomProver. \end{thebibliography} \end{document}