login
A322572
Start with a(1) = 1, a(2) = 2. Thereafter, if a(n) is prime, a(n+1) = a(n) + 1. If a(n) is composite, look for its greatest factor other than itself (k, say) earlier in the sequence. If k is found, a(n+1) = a(n) + the number of steps back to the most recent appearance of k. If k is not found, a(n+1) = a(n) - k.
2
1, 2, 3, 4, 6, 8, 10, 5, 6, 12, 13, 14, 7, 8, 18, 9, 22, 11, 12, 22, 24, 26, 37, 38, 19, 20, 39, 55, 65, 83, 84, 42, 21, 41, 42, 44, 60, 30, 15, 46, 23, 24, 47, 48, 50, 25, 63, 77, 107, 108, 54, 27, 63, 83, 84, 104, 52, 87, 58, 29, 30, 52, 92, 115, 138, 69, 94, 118, 59
OFFSET
1,2
COMMENTS
It is unknown whether every natural number eventually appears in the sequence, but some have notably late entry points. For instance, a(n) = 28 for the first time (possibly only time) at n = 582. 280 first appears at n = 16175. 508 and 624 are the only values less than 1000 that do not appear in the first 50000 terms. After n = 4, the first time a(n) = n is at term 766. Thereafter, a(n) = n at 1952, 4682, 6367, 6368, and not again within the first 50000 terms.
MATHEMATICA
gf[n_] := n/FactorInteger[n][[1, 1]]; s = {1, 2}; Do[a = s[[-1]] + If[PrimeQ[s[[-1]]], 1, m = If[(p = Position[s, _?(# == (k = gf[s[[-1]]]) &)]) == {}, -k, Length[s] - p[[-1, 1]]]]; AppendTo[s, a], {100}]; s (* Amiram Eldar, Sep 06 2019 *)
PROG
(PARI) { a = vector(69); for (n=1, #a, if (n==1, a[n] = 1, n==2, a[n] = 2, isprime(a[n-1]), a[n] = a[n-1]+1, d = divisors(a[n-1]); k = d[#d-1]; a[n] = a[n-1]-k; forstep (m=n-2, 1, -1, if (a[m]==k, a[n] = a[n-1] + n-1 - m; break))); print1 (a[n] ", ")) } \\ Rémy Sigrist, Sep 06 2019
CROSSREFS
Similar to the Van Eck sequence, A181391. See also A309035.
Sequence in context: A151545 A353383 A097274 * A375564 A254438 A121539
KEYWORD
nonn
AUTHOR
Max Tohline, Aug 29 2019
STATUS
approved