A135543 Record number of steps under iterations of "map n to n - (largest prime <= n)" (A064722) until reaching the limiting value 0 or 1. Also, places where A121561 reaches a new record.
1, 2, 9, 122, 1357323
Offset: 0
Examples
a(4) = 1357323 because after iterating n - (largest prime <= n) we get: 1357323 - 1357201 = 122 => 122 - 113 = 9 => 9 - 7 = 2 => 2 - 2 = 0, which takes 4 steps.
Links
- Thomas R. Nicely, First known occurrence prime gaps (1000000 to 999999998).
Programs
-
Mathematica
LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@ k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@d; c++ ]; c]; lst = {}; record = -1; Do[ a = f@n; If[a > record, record = a; AppendTo[lst, a]; Print@ n], {n, 100}] (* Robert G. Wilson v *)
-
Python
from sympy import prevprime from functools import lru_cache from itertools import count, islice @lru_cache(maxsize=None) def f(n): return 0 if n == 0 or n == 1 else 1 + f(n - prevprime(n+1)) def agen(record=-1): for k in count(1): if f(k) > record: record = f(k); yield k print(list(islice(agen(), 4))) # Michael S. Branicky, Jul 26 2022
Formula
Iterate n - (largest prime <= n) until reaching 0 or 1. Count the iterations required to reach 0 or 1 and determine if it is a new record.
From Pontus von Brömssen, Jul 31 2022: (Start)
a(n) = A104138(a(n-1)) + a(n-1) for n >= 2.
A121561(a(n)) = n.
a(n) = A175079(n) - 1 for n >= 1, i.e., the conjecture in the Comments is false. This follows from the result that A175078(n) = A121561(n-1) for n >= 2.
(End)
Comments