The Iterated Distance-to-Prime (IDP) function d (n), defined as the minimum distance from an integer, n, to the nearest prime, exhibits a unique dynamical behaviour under iteration. This paper explores the behaviour of dk (n), where dk (n) denotes the k-th iteration of d (n) and argues that for most integers n, d2 (n) converges to the attractor set 0, 1, 2. We introduce a density-based argument, showing that the set of exceptions, n: d2 (n) > M, has a natural density zero for any threshold M. We also identify the ‘Elite’ class of numbers where d2 (n) ≥ 4, and provide insights into the role of prime gaps in the rarity of such numbers. Finally, we formalise the limit set and discuss the implications of Cramér’s conjecture 1 in explaining the exponential rarity of large d2 (n) values.
Gabriel Enrique Alvarado Hernandez (Thu,) studied this question.